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.
- pangea/__init__.py +9 -1
- pangea/asyncio/__init__.py +1 -0
- pangea/asyncio/file_uploader.py +4 -2
- pangea/asyncio/request.py +70 -169
- pangea/asyncio/services/__init__.py +2 -1
- pangea/asyncio/services/ai_guard.py +9 -12
- pangea/asyncio/services/audit.py +13 -307
- pangea/asyncio/services/authn.py +40 -32
- pangea/asyncio/services/authz.py +51 -17
- pangea/asyncio/services/base.py +4 -0
- pangea/asyncio/services/file_scan.py +8 -2
- pangea/asyncio/services/intel.py +26 -28
- pangea/asyncio/services/redact.py +11 -268
- pangea/asyncio/services/sanitize.py +5 -1
- pangea/asyncio/services/share.py +5 -1
- pangea/asyncio/services/vault.py +71 -55
- pangea/audit_logger.py +3 -1
- pangea/deep_verify.py +13 -13
- pangea/deprecated.py +1 -1
- pangea/dump_audit.py +2 -3
- pangea/exceptions.py +8 -5
- pangea/file_uploader.py +4 -0
- pangea/request.py +80 -200
- pangea/response.py +21 -18
- pangea/services/__init__.py +2 -1
- pangea/services/ai_guard.py +35 -24
- pangea/services/audit/audit.py +17 -314
- pangea/services/audit/models.py +69 -307
- pangea/services/audit/signing.py +1 -1
- pangea/services/audit/util.py +10 -10
- pangea/services/authn/authn.py +39 -31
- pangea/services/authn/models.py +183 -148
- pangea/services/authz.py +108 -60
- pangea/services/base.py +7 -4
- pangea/services/embargo.py +6 -0
- pangea/services/file_scan.py +8 -2
- pangea/services/intel.py +36 -19
- pangea/services/redact.py +14 -476
- pangea/services/sanitize.py +5 -1
- pangea/services/share/share.py +13 -7
- pangea/services/vault/models/asymmetric.py +4 -0
- pangea/services/vault/models/common.py +15 -12
- pangea/services/vault/models/keys.py +4 -9
- pangea/services/vault/models/secret.py +3 -8
- pangea/services/vault/models/symmetric.py +4 -0
- pangea/services/vault/vault.py +69 -59
- pangea/tools.py +13 -9
- pangea/utils.py +3 -5
- pangea/verify_audit.py +23 -27
- {pangea_sdk-6.2.0b1.dist-info → pangea_sdk-6.3.0.dist-info}/METADATA +36 -17
- pangea_sdk-6.3.0.dist-info/RECORD +60 -0
- {pangea_sdk-6.2.0b1.dist-info → pangea_sdk-6.3.0.dist-info}/WHEEL +1 -1
- pangea/asyncio/services/management.py +0 -576
- pangea/services/management.py +0 -720
- pangea_sdk-6.2.0b1.dist-info/RECORD +0 -62
pangea/asyncio/services/audit.py
CHANGED
@@ -1,11 +1,14 @@
|
|
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
|
-
from
|
7
|
-
|
8
|
-
from pydantic import TypeAdapter
|
10
|
+
from collections.abc import Mapping
|
11
|
+
from typing import Any, Dict, Iterable, List, Optional, Sequence, Union
|
9
12
|
|
10
13
|
import pangea.exceptions as pexc
|
11
14
|
from pangea.asyncio.services.base import ServiceBaseAsync
|
@@ -14,13 +17,11 @@ from pangea.response import PangeaResponse, PangeaResponseResult
|
|
14
17
|
from pangea.services.audit.audit import AuditBase
|
15
18
|
from pangea.services.audit.exceptions import AuditException
|
16
19
|
from pangea.services.audit.models import (
|
17
|
-
AuditSchema,
|
18
20
|
DownloadFormat,
|
19
21
|
DownloadRequest,
|
20
22
|
DownloadResult,
|
21
23
|
Event,
|
22
24
|
ExportRequest,
|
23
|
-
ForwardingConfiguration,
|
24
25
|
LogBulkResult,
|
25
26
|
LogResult,
|
26
27
|
PublishedRoot,
|
@@ -33,9 +34,6 @@ from pangea.services.audit.models import (
|
|
33
34
|
SearchRequest,
|
34
35
|
SearchResultOutput,
|
35
36
|
SearchResultRequest,
|
36
|
-
ServiceConfig,
|
37
|
-
ServiceConfigFilter,
|
38
|
-
ServiceConfigListResult,
|
39
37
|
)
|
40
38
|
from pangea.services.audit.util import format_datetime
|
41
39
|
|
@@ -70,7 +68,7 @@ class AuditAsync(ServiceBaseAsync, AuditBase):
|
|
70
68
|
token: str,
|
71
69
|
config: PangeaConfig | None = None,
|
72
70
|
private_key_file: str = "",
|
73
|
-
public_key_info:
|
71
|
+
public_key_info: Mapping[str, str] = {},
|
74
72
|
tenant_id: str | None = None,
|
75
73
|
logger_name: str = "pangea",
|
76
74
|
config_id: str | None = None,
|
@@ -142,7 +140,7 @@ class AuditAsync(ServiceBaseAsync, AuditBase):
|
|
142
140
|
A PangeaResponse where the hash of event data and optional verbose
|
143
141
|
results are returned in the response.result field.
|
144
142
|
Available response fields can be found in our
|
145
|
-
[API documentation](https://pangea.cloud/docs/api/audit
|
143
|
+
[API documentation](https://pangea.cloud/docs/api/audit#/v1/log-post).
|
146
144
|
|
147
145
|
Examples:
|
148
146
|
try:
|
@@ -193,7 +191,7 @@ class AuditAsync(ServiceBaseAsync, AuditBase):
|
|
193
191
|
Returns:
|
194
192
|
A PangeaResponse where the hash of event data and optional verbose
|
195
193
|
results are returned in the response.result field.
|
196
|
-
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/audit
|
194
|
+
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/audit#/v1/log-post).
|
197
195
|
|
198
196
|
Examples:
|
199
197
|
response = await audit.log_event({"message": "hello world"}, verbose=True)
|
@@ -229,7 +227,7 @@ class AuditAsync(ServiceBaseAsync, AuditBase):
|
|
229
227
|
Returns:
|
230
228
|
A PangeaResponse where the hash of event data and optional verbose
|
231
229
|
results are returned in the response.result field.
|
232
|
-
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/audit
|
230
|
+
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/audit#/v1/log-post).
|
233
231
|
|
234
232
|
Examples:
|
235
233
|
FIXME:
|
@@ -266,7 +264,7 @@ class AuditAsync(ServiceBaseAsync, AuditBase):
|
|
266
264
|
Returns:
|
267
265
|
A PangeaResponse where the hash of event data and optional verbose
|
268
266
|
results are returned in the response.result field.
|
269
|
-
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/audit
|
267
|
+
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/audit#/v1/log-post).
|
270
268
|
|
271
269
|
Examples:
|
272
270
|
FIXME:
|
@@ -335,8 +333,8 @@ class AuditAsync(ServiceBaseAsync, AuditBase):
|
|
335
333
|
|
336
334
|
Returns:
|
337
335
|
A PangeaResponse[SearchOutput] where the first page of matched events is returned in the
|
338
|
-
response.result field. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/audit
|
339
|
-
Pagination can be found in the [search results endpoint](https://pangea.cloud/docs/api/audit
|
336
|
+
response.result field. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/audit#/v1/results-post).
|
337
|
+
Pagination can be found in the [search results endpoint](https://pangea.cloud/docs/api/audit#/v1/download_results-post).
|
340
338
|
|
341
339
|
Examples:
|
342
340
|
response: PangeaResponse[SearchOutput] = audit.search(query="message:test", search_restriction={'source': ["monitor"]}, limit=1, verify_consistency=True, verify_events=True)
|
@@ -597,298 +595,6 @@ class AuditAsync(ServiceBaseAsync, AuditBase):
|
|
597
595
|
)
|
598
596
|
return await self.request.post("v1/download_results", DownloadResult, data=input.model_dump(exclude_none=True))
|
599
597
|
|
600
|
-
async def get_service_config(self, config_id: str) -> PangeaResponse[ServiceConfig]:
|
601
|
-
"""
|
602
|
-
Get a service config.
|
603
|
-
|
604
|
-
OperationId: audit_post_v1beta_config
|
605
|
-
|
606
|
-
Args:
|
607
|
-
id: The config ID
|
608
|
-
"""
|
609
|
-
|
610
|
-
response = await self.request.post("v1beta/config", PangeaResponseResult, data={"id": config_id})
|
611
|
-
response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
|
612
|
-
return cast(PangeaResponse[ServiceConfig], response)
|
613
|
-
|
614
|
-
@overload
|
615
|
-
async def create_service_config(
|
616
|
-
self,
|
617
|
-
version: Literal[1],
|
618
|
-
name: str,
|
619
|
-
*,
|
620
|
-
cold_query_result_retention: str | None = None,
|
621
|
-
hot_storage: str | None = None,
|
622
|
-
query_result_retention: str | None = None,
|
623
|
-
redact_service_config_id: str | None = None,
|
624
|
-
redaction_fields: Sequence[str] | None = None,
|
625
|
-
retention: str | None = None,
|
626
|
-
vault_key_id: str | None = None,
|
627
|
-
vault_service_config_id: str | None = None,
|
628
|
-
vault_sign: bool | None = None,
|
629
|
-
) -> PangeaResponse[ServiceConfig]:
|
630
|
-
"""
|
631
|
-
Create a v1 service config.
|
632
|
-
|
633
|
-
OperationId: audit_post_v1beta_config_create
|
634
|
-
|
635
|
-
Args:
|
636
|
-
name: Configuration name
|
637
|
-
cold_query_result_retention: Retention window for cold query result / state information.
|
638
|
-
hot_storage: Retention window to keep audit logs in hot storage.
|
639
|
-
query_result_retention: Length of time to preserve server-side query result caching.
|
640
|
-
redact_service_config_id: A redact service config that will be used to redact PII from logs.
|
641
|
-
redaction_fields: Fields to perform redaction against.
|
642
|
-
retention: Retention window to store audit logs.
|
643
|
-
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
644
|
-
vault_service_config_id: A vault service config that will be used to sign logs.
|
645
|
-
vault_sign: Enable/disable event signing.
|
646
|
-
"""
|
647
|
-
|
648
|
-
@overload
|
649
|
-
async def create_service_config(
|
650
|
-
self,
|
651
|
-
version: Literal[2],
|
652
|
-
name: str,
|
653
|
-
*,
|
654
|
-
schema: AuditSchema,
|
655
|
-
cold_query_result_retention: str | None = None,
|
656
|
-
forwarding_configuration: ForwardingConfiguration | None = None,
|
657
|
-
hot_storage: str | None = None,
|
658
|
-
query_result_retention: str | None = None,
|
659
|
-
redact_service_config_id: str | None = None,
|
660
|
-
retention: str | None = None,
|
661
|
-
vault_key_id: str | None = None,
|
662
|
-
vault_service_config_id: str | None = None,
|
663
|
-
vault_sign: bool | None = None,
|
664
|
-
) -> PangeaResponse[ServiceConfig]:
|
665
|
-
"""
|
666
|
-
Create a v2 service config.
|
667
|
-
|
668
|
-
OperationId: audit_post_v1beta_config_create
|
669
|
-
|
670
|
-
Args:
|
671
|
-
name: Configuration name
|
672
|
-
schema: Audit log field configuration. Only settable at create time.
|
673
|
-
cold_query_result_retention: Retention window for cold query result / state information.
|
674
|
-
forwarding_configuration: Configuration for forwarding audit logs to external systems.
|
675
|
-
hot_storage: Retention window to keep audit logs in hot storage.
|
676
|
-
query_result_retention: Length of time to preserve server-side query result caching.
|
677
|
-
redact_service_config_id: A redact service config that will be used to redact PII from logs.
|
678
|
-
retention: Retention window to store audit logs.
|
679
|
-
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
680
|
-
vault_service_config_id: A vault service config that will be used to sign logs.
|
681
|
-
vault_sign: Enable/disable event signing.
|
682
|
-
"""
|
683
|
-
|
684
|
-
@overload
|
685
|
-
async def create_service_config(
|
686
|
-
self,
|
687
|
-
version: Literal[3],
|
688
|
-
name: str,
|
689
|
-
*,
|
690
|
-
schema: AuditSchema,
|
691
|
-
cold_storage: str | None = None,
|
692
|
-
hot_storage: str | None = None,
|
693
|
-
warm_storage: str | None = None,
|
694
|
-
redact_service_config_id: str | None = None,
|
695
|
-
vault_service_config_id: str | None = None,
|
696
|
-
vault_key_id: str | None = None,
|
697
|
-
vault_sign: bool | None = None,
|
698
|
-
forwarding_configuration: ForwardingConfiguration | None = None,
|
699
|
-
) -> PangeaResponse[ServiceConfig]:
|
700
|
-
"""
|
701
|
-
Create a v3 service config.
|
702
|
-
|
703
|
-
OperationId: audit_post_v1beta_config_create
|
704
|
-
|
705
|
-
Args:
|
706
|
-
name: Configuration name
|
707
|
-
schema: Audit log field configuration. Only settable at create time.
|
708
|
-
cold_storage: Retention window for logs in cold storage. Deleted afterwards.
|
709
|
-
hot_storage: Retention window for logs in hot storage. Migrated to warm, cold, or deleted afterwards.
|
710
|
-
warm_storage: Retention window for logs in warm storage. Migrated to cold or deleted afterwards.
|
711
|
-
redact_service_config_id: A redact service config that will be used to redact PII from logs.
|
712
|
-
vault_service_config_id: A vault service config that will be used to sign logs.
|
713
|
-
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
714
|
-
vault_sign: Enable/disable event signing.
|
715
|
-
forwarding_configuration: Configuration for forwarding audit logs to external systems.
|
716
|
-
"""
|
717
|
-
|
718
|
-
async def create_service_config(
|
719
|
-
self,
|
720
|
-
version: Literal[1, 2, 3],
|
721
|
-
name: str,
|
722
|
-
*,
|
723
|
-
cold_query_result_retention: str | None = None,
|
724
|
-
cold_storage: str | None = None,
|
725
|
-
forwarding_configuration: ForwardingConfiguration | None = None,
|
726
|
-
hot_storage: str | None = None,
|
727
|
-
query_result_retention: str | None = None,
|
728
|
-
redact_service_config_id: str | None = None,
|
729
|
-
redaction_fields: Sequence[str] | None = None,
|
730
|
-
retention: str | None = None,
|
731
|
-
schema: AuditSchema | None = None,
|
732
|
-
vault_key_id: str | None = None,
|
733
|
-
vault_service_config_id: str | None = None,
|
734
|
-
vault_sign: bool | None = None,
|
735
|
-
warm_storage: str | None = None,
|
736
|
-
) -> PangeaResponse[ServiceConfig]:
|
737
|
-
"""
|
738
|
-
Create a service config.
|
739
|
-
|
740
|
-
OperationId: audit_post_v1beta_config_create
|
741
|
-
|
742
|
-
Args:
|
743
|
-
name: Configuration name
|
744
|
-
cold_query_result_retention: Retention window for cold query result / state information.
|
745
|
-
cold_storage: Retention window for logs in cold storage. Deleted afterwards.
|
746
|
-
forwarding_configuration: Configuration for forwarding audit logs to external systems.
|
747
|
-
hot_storage: Retention window to keep audit logs in hot storage.
|
748
|
-
query_result_retention: Length of time to preserve server-side query result caching.
|
749
|
-
redact_service_config_id: A redact service config that will be used to redact PII from logs.
|
750
|
-
redaction_fields: Fields to perform redaction against.
|
751
|
-
retention: Retention window to store audit logs.
|
752
|
-
schema: Audit log field configuration. Only settable at create time.
|
753
|
-
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
754
|
-
vault_service_config_id: A vault service config that will be used to sign logs.
|
755
|
-
vault_sign: Enable/disable event signing.
|
756
|
-
warm_storage: Retention window for logs in warm storage. Migrated to cold or deleted afterwards.
|
757
|
-
"""
|
758
|
-
|
759
|
-
response = await self.request.post(
|
760
|
-
"v1beta/config/create",
|
761
|
-
PangeaResponseResult,
|
762
|
-
data={
|
763
|
-
"cold_query_result_retention": cold_query_result_retention,
|
764
|
-
"cold_storage": cold_storage,
|
765
|
-
"forwarding_configuration": forwarding_configuration,
|
766
|
-
"hot_storage": hot_storage,
|
767
|
-
"name": name,
|
768
|
-
"query_result_retention": query_result_retention,
|
769
|
-
"redact_service_config_id": redact_service_config_id,
|
770
|
-
"redaction_fields": redaction_fields,
|
771
|
-
"retention": retention,
|
772
|
-
"schema": schema,
|
773
|
-
"vault_key_id": vault_key_id,
|
774
|
-
"vault_service_config_id": vault_service_config_id,
|
775
|
-
"vault_sign": vault_sign,
|
776
|
-
"warm_storage": warm_storage,
|
777
|
-
"version": version,
|
778
|
-
},
|
779
|
-
)
|
780
|
-
response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
|
781
|
-
return cast(PangeaResponse[ServiceConfig], response)
|
782
|
-
|
783
|
-
async def update_service_config(
|
784
|
-
self,
|
785
|
-
config_id: str,
|
786
|
-
*,
|
787
|
-
name: str,
|
788
|
-
updated_at: datetime.datetime,
|
789
|
-
# Optionals.
|
790
|
-
cold_query_result_retention: str | None = None,
|
791
|
-
cold_storage: str | None = None,
|
792
|
-
forwarding_configuration: ForwardingConfiguration | None = None,
|
793
|
-
hot_storage: str | None = None,
|
794
|
-
query_result_retention: str | None = None,
|
795
|
-
redact_service_config_id: str | None = None,
|
796
|
-
retention: str | None = None,
|
797
|
-
schema: AuditSchema | None = None,
|
798
|
-
vault_key_id: str | None = None,
|
799
|
-
vault_service_config_id: str | None = None,
|
800
|
-
vault_sign: bool | None = None,
|
801
|
-
warm_storage: str | None = None,
|
802
|
-
) -> PangeaResponse[ServiceConfig]:
|
803
|
-
"""
|
804
|
-
Update a service config.
|
805
|
-
|
806
|
-
OperationId: audit_post_v1beta_config_update
|
807
|
-
|
808
|
-
Args:
|
809
|
-
id: The config ID
|
810
|
-
name: Configuration name
|
811
|
-
updated_at: The DB timestamp when this config was last updated at
|
812
|
-
cold_query_result_retention: Retention window for cold query result / state information.
|
813
|
-
cold_storage: Retention window for logs in cold storage. Deleted afterwards.
|
814
|
-
forwarding_configuration: Configuration for forwarding audit logs to external systems
|
815
|
-
hot_storage: Retention window to keep audit logs in hot storage
|
816
|
-
query_result_retention: Length of time to preserve server-side query result caching
|
817
|
-
redact_service_config_id: A redact service config that will be used to redact PII from logs
|
818
|
-
retention: Retention window to store audit logs
|
819
|
-
schema: Audit log field configuration
|
820
|
-
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
821
|
-
vault_service_config_id: A vault service config that will be used to sign logs
|
822
|
-
vault_sign: Enable/disable event signing
|
823
|
-
warm_storage: Retention window for logs in warm storage. Migrated to cold or deleted afterwards.
|
824
|
-
"""
|
825
|
-
|
826
|
-
response = await self.request.post(
|
827
|
-
"v1beta/config/update",
|
828
|
-
PangeaResponseResult,
|
829
|
-
data={
|
830
|
-
"id": config_id,
|
831
|
-
"name": name,
|
832
|
-
"updated_at": updated_at,
|
833
|
-
# Optionals.
|
834
|
-
"cold_query_result_retention": cold_query_result_retention,
|
835
|
-
"cold_storage": cold_storage,
|
836
|
-
"forwarding_configuration": forwarding_configuration,
|
837
|
-
"hot_storage": hot_storage,
|
838
|
-
"query_result_retention": query_result_retention,
|
839
|
-
"redact_service_config_id": redact_service_config_id,
|
840
|
-
"retention": retention,
|
841
|
-
"schema": schema,
|
842
|
-
"vault_key_id": vault_key_id,
|
843
|
-
"vault_service_config_id": vault_service_config_id,
|
844
|
-
"vault_sign": vault_sign,
|
845
|
-
"warm_storage": warm_storage,
|
846
|
-
},
|
847
|
-
)
|
848
|
-
response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
|
849
|
-
return cast(PangeaResponse[ServiceConfig], response)
|
850
|
-
|
851
|
-
async def delete_service_config(self, config_id: str) -> PangeaResponse[ServiceConfig]:
|
852
|
-
"""
|
853
|
-
Delete a service config.
|
854
|
-
|
855
|
-
OperationId: audit_post_v1beta_config_delete
|
856
|
-
|
857
|
-
Args:
|
858
|
-
id: The config ID
|
859
|
-
"""
|
860
|
-
|
861
|
-
response = await self.request.post("v1beta/config/delete", PangeaResponseResult, data={"id": config_id})
|
862
|
-
response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
|
863
|
-
return cast(PangeaResponse[ServiceConfig], response)
|
864
|
-
|
865
|
-
async def list_service_configs(
|
866
|
-
self,
|
867
|
-
*,
|
868
|
-
filter: ServiceConfigFilter | None = None,
|
869
|
-
last: str | None = None,
|
870
|
-
order: Literal["asc", "desc"] | None = None,
|
871
|
-
order_by: Literal["id", "created_at", "updated_at"] | None = None,
|
872
|
-
size: int | None = None,
|
873
|
-
) -> PangeaResponse[ServiceConfigListResult]:
|
874
|
-
"""
|
875
|
-
List service configs.
|
876
|
-
|
877
|
-
OperationId: audit_post_v1beta_config_list
|
878
|
-
|
879
|
-
Args:
|
880
|
-
last: Reflected value from a previous response to obtain the next page of results.
|
881
|
-
order: Order results asc(ending) or desc(ending).
|
882
|
-
order_by: Which field to order results by.
|
883
|
-
size: Maximum results to include in the response.
|
884
|
-
"""
|
885
|
-
|
886
|
-
return await self.request.post(
|
887
|
-
"v1beta/config/list",
|
888
|
-
ServiceConfigListResult,
|
889
|
-
data={"filter": filter, "last": last, "order": order, "order_by": order_by, "size": size},
|
890
|
-
)
|
891
|
-
|
892
598
|
async def update_published_roots(self, result: SearchResultOutput):
|
893
599
|
"""Fetches series of published root hashes from Arweave
|
894
600
|
|
pangea/asyncio/services/authn.py
CHANGED
@@ -1,7 +1,12 @@
|
|
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
|
|
9
|
+
from collections.abc import Mapping
|
5
10
|
from typing import Dict, List, Literal, Optional, Union
|
6
11
|
|
7
12
|
import pangea.services.authn.models as m
|
@@ -127,7 +132,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
127
132
|
Returns:
|
128
133
|
A PangeaResponse with a list of sessions in the response.result field.
|
129
134
|
Available response fields can be found in our
|
130
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/session#/v2/session/list).
|
135
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/session#/v2/session/list-post).
|
131
136
|
|
132
137
|
Examples:
|
133
138
|
response = authn.session.list()
|
@@ -192,7 +197,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
192
197
|
Returns:
|
193
198
|
A PangeaResponse with credentials for a login session in the response.result field.
|
194
199
|
Available response fields can be found in our
|
195
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/client/userinfo).
|
200
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/client/userinfo-post).
|
196
201
|
|
197
202
|
Examples:
|
198
203
|
response = authn.client.userinfo(
|
@@ -217,7 +222,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
217
222
|
Returns:
|
218
223
|
A PangeaResponse with jwt verification keys in the response.result field.
|
219
224
|
Available response fields can be found in our
|
220
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/jwt#/v2/client/jwks).
|
225
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/jwt#/v2/client/jwks-post).
|
221
226
|
|
222
227
|
Examples:
|
223
228
|
response = authn.client.jwks()
|
@@ -290,7 +295,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
290
295
|
Returns:
|
291
296
|
A PangeaResponse with a list of sessions in the response.result field.
|
292
297
|
Available response fields can be found in our
|
293
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/session#/v2/client/session/list).
|
298
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/session#/v2/client/session/list-post).
|
294
299
|
|
295
300
|
Examples:
|
296
301
|
response = authn.client.session.list(
|
@@ -348,7 +353,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
348
353
|
Returns:
|
349
354
|
A PangeaResponse with credentials for a login session in the response.result field.
|
350
355
|
Available response fields can be found in our
|
351
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/session#/v2/client/session/refresh).
|
356
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/session#/v2/client/session/refresh-post).
|
352
357
|
|
353
358
|
Examples:
|
354
359
|
response = authn.client.session.refresh(
|
@@ -432,7 +437,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
432
437
|
) -> None:
|
433
438
|
super().__init__(token, config, logger_name=logger_name)
|
434
439
|
|
435
|
-
async def check(self, token:
|
440
|
+
async def check(self, token: m.Token) -> PangeaResponse[m.ClientTokenCheckResult]:
|
436
441
|
"""
|
437
442
|
Check a token
|
438
443
|
|
@@ -441,22 +446,19 @@ class AuthNAsync(ServiceBaseAsync):
|
|
441
446
|
OperationId: authn_post_v2_client_token_check
|
442
447
|
|
443
448
|
Args:
|
444
|
-
token
|
449
|
+
token: A token value
|
445
450
|
|
446
451
|
Returns:
|
447
452
|
A PangeaResponse with a token and its information in the response.result field.
|
448
453
|
Available response fields can be found in our
|
449
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/client/token/check).
|
454
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/client/token/check-post).
|
450
455
|
|
451
456
|
Examples:
|
452
|
-
response = authn.client.token_endpoints.check(
|
457
|
+
response = await authn.client.token_endpoints.check(
|
453
458
|
token="ptu_wuk7tvtpswyjtlsx52b7yyi2l7zotv4a",
|
454
459
|
)
|
455
460
|
"""
|
456
|
-
|
457
|
-
return await self.request.post(
|
458
|
-
"v2/client/token/check", m.ClientTokenCheckResult, data=input.model_dump(exclude_none=True)
|
459
|
-
)
|
461
|
+
return await self.request.post("v2/client/token/check", m.ClientTokenCheckResult, data={"token": token})
|
460
462
|
|
461
463
|
class UserAsync(ServiceBaseAsync):
|
462
464
|
service_name = _SERVICE_NAME
|
@@ -475,7 +477,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
475
477
|
async def create(
|
476
478
|
self,
|
477
479
|
email: str,
|
478
|
-
profile:
|
480
|
+
profile: Mapping[str, str],
|
479
481
|
*,
|
480
482
|
username: str | None = None,
|
481
483
|
) -> PangeaResponse[m.UserCreateResult]:
|
@@ -494,7 +496,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
494
496
|
Returns:
|
495
497
|
A PangeaResponse with a user and its information in the response.result field.
|
496
498
|
Available response fields can be found in our
|
497
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/create).
|
499
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/create-post).
|
498
500
|
|
499
501
|
Examples:
|
500
502
|
response = authn.user.create(
|
@@ -563,7 +565,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
563
565
|
Returns:
|
564
566
|
A PangeaResponse with a pending user invitation in the response.result field.
|
565
567
|
Available response fields can be found in our
|
566
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/invite#/v2/user/invite).
|
568
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/invite#/v2/user/invite-post).
|
567
569
|
|
568
570
|
Examples:
|
569
571
|
response = authn.user.invite(
|
@@ -608,7 +610,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
608
610
|
Returns:
|
609
611
|
A PangeaResponse with a user and its information in the response.result field.
|
610
612
|
Available response fields can be found in our
|
611
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/update).
|
613
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/update-post).
|
612
614
|
|
613
615
|
Examples:
|
614
616
|
response = authn.user.update(
|
@@ -652,7 +654,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
652
654
|
Returns:
|
653
655
|
A PangeaResponse with a list of users in the response.result field.
|
654
656
|
Available response fields can be found in our
|
655
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/list).
|
657
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/list-post).
|
656
658
|
|
657
659
|
Examples:
|
658
660
|
response = authn.user.list()
|
@@ -705,7 +707,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
705
707
|
Returns:
|
706
708
|
A PangeaResponse with a list of pending user invitations in the response.result field.
|
707
709
|
Available response fields can be found in our
|
708
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/invite#/v2/user/invite/list).
|
710
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/invite#/v2/user/invite/list-post).
|
709
711
|
Examples:
|
710
712
|
response = authn.user.invites.list()
|
711
713
|
"""
|
@@ -809,7 +811,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
809
811
|
Returns:
|
810
812
|
A PangeaResponse with a list of authenticators in the response.result field.
|
811
813
|
Available response fields can be found in our
|
812
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/authenticators/list).
|
814
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/authenticators/list-post).
|
813
815
|
|
814
816
|
Examples:
|
815
817
|
response = authn.user.authenticators.list(
|
@@ -852,7 +854,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
852
854
|
Returns:
|
853
855
|
A PangeaResponse with a user and its information in the response.result field.
|
854
856
|
Available response fields can be found in our
|
855
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/profile/get).
|
857
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/profile/get-post).
|
856
858
|
|
857
859
|
Examples:
|
858
860
|
response = authn.user.profile.get(
|
@@ -866,7 +868,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
866
868
|
|
867
869
|
async def update(
|
868
870
|
self,
|
869
|
-
profile:
|
871
|
+
profile: Mapping[str, str],
|
870
872
|
id: str | None = None,
|
871
873
|
email: str | None = None,
|
872
874
|
*,
|
@@ -888,7 +890,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
888
890
|
Returns:
|
889
891
|
A PangeaResponse with a user and its information in the response.result field.
|
890
892
|
Available response fields can be found in our
|
891
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/profile/update).
|
893
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/profile/update-post).
|
892
894
|
|
893
895
|
Examples:
|
894
896
|
response = authn.user.profile.update(
|
@@ -982,7 +984,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
982
984
|
Returns:
|
983
985
|
A PangeaResponse with credentials for a login session in the response.result field.
|
984
986
|
Available response fields can be found in our
|
985
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/flow/complete).
|
987
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/flow/complete-post).
|
986
988
|
|
987
989
|
Examples:
|
988
990
|
response = authn.flow.complete(
|
@@ -995,7 +997,10 @@ class AuthNAsync(ServiceBaseAsync):
|
|
995
997
|
)
|
996
998
|
|
997
999
|
async def restart(
|
998
|
-
self,
|
1000
|
+
self,
|
1001
|
+
flow_id: str,
|
1002
|
+
choice: m.FlowChoice,
|
1003
|
+
data: m.FlowRestartData = {}, # noqa: B006
|
999
1004
|
) -> PangeaResponse[m.FlowRestartResult]:
|
1000
1005
|
"""
|
1001
1006
|
Restart a sign-up/sign-in flow
|
@@ -1013,7 +1018,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
1013
1018
|
A PangeaResponse with information about next steps needed
|
1014
1019
|
to complete a flow in the response.result field.
|
1015
1020
|
Available response fields can be found in our
|
1016
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/flow/restart).
|
1021
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/flow/restart-post).
|
1017
1022
|
|
1018
1023
|
Examples:
|
1019
1024
|
response = authn.flow.restart(
|
@@ -1052,7 +1057,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
1052
1057
|
A PangeaResponse with information about next steps needed
|
1053
1058
|
to complete a flow in the response.result field.
|
1054
1059
|
Available response fields can be found in our
|
1055
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/flow/start).
|
1060
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/flow/start-post).
|
1056
1061
|
|
1057
1062
|
Examples:
|
1058
1063
|
response = authn.flow.start(
|
@@ -1068,7 +1073,10 @@ class AuthNAsync(ServiceBaseAsync):
|
|
1068
1073
|
return await self.request.post("v2/flow/start", m.FlowStartResult, data=input.model_dump(exclude_none=True))
|
1069
1074
|
|
1070
1075
|
async def update(
|
1071
|
-
self,
|
1076
|
+
self,
|
1077
|
+
flow_id: str,
|
1078
|
+
choice: m.FlowChoice,
|
1079
|
+
data: m.FlowUpdateData = {}, # noqa: B006
|
1072
1080
|
) -> PangeaResponse[m.FlowUpdateResult]:
|
1073
1081
|
"""
|
1074
1082
|
Update a sign-up/sign-in flow
|
@@ -1086,7 +1094,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
1086
1094
|
A PangeaResponse with information about next steps needed
|
1087
1095
|
to complete a flow in the response.result field.
|
1088
1096
|
Available response fields can be found in our
|
1089
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/flow/update).
|
1097
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/flow/update-post).
|
1090
1098
|
|
1091
1099
|
Examples:
|
1092
1100
|
response = authn.flow.update(
|
@@ -1133,7 +1141,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
1133
1141
|
Returns:
|
1134
1142
|
A PangeaResponse with a EULA object in the response.result field.
|
1135
1143
|
Available response fields can be found in our
|
1136
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/agreements#/v2/agreements/create).
|
1144
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/agreements#/v2/agreements/create-post).
|
1137
1145
|
|
1138
1146
|
Examples:
|
1139
1147
|
response = authn.agreements.create(
|
@@ -1200,7 +1208,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
1200
1208
|
Returns:
|
1201
1209
|
A PangeaResponse with a list of EULA objects in the response.result field.
|
1202
1210
|
Available response fields can be found in our
|
1203
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/agreements#/v2/agreements/list).
|
1211
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/agreements#/v2/agreements/list-post).
|
1204
1212
|
|
1205
1213
|
Examples:
|
1206
1214
|
response = authn.agreements.list()
|
@@ -1238,7 +1246,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
1238
1246
|
Returns:
|
1239
1247
|
A PangeaResponse with the updated EULA object in the response.result field.
|
1240
1248
|
Available response fields can be found in our
|
1241
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/agreements#/v2/agreements/update).
|
1249
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/agreements#/v2/agreements/update-post).
|
1242
1250
|
|
1243
1251
|
Examples:
|
1244
1252
|
response = authn.agreements.update(
|