pangea-sdk 6.0.0__py3-none-any.whl → 6.2.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 +153 -19
- pangea/asyncio/services/__init__.py +1 -0
- pangea/asyncio/services/audit.py +300 -1
- pangea/asyncio/services/authn.py +171 -14
- pangea/asyncio/services/authz.py +28 -28
- pangea/asyncio/services/management.py +576 -0
- pangea/asyncio/services/redact.py +265 -4
- pangea/request.py +155 -19
- pangea/services/__init__.py +1 -0
- pangea/services/audit/audit.py +301 -1
- pangea/services/audit/models.py +275 -0
- pangea/services/authn/authn.py +177 -18
- pangea/services/authn/models.py +94 -0
- pangea/services/authz.py +65 -30
- pangea/services/management.py +720 -0
- pangea/services/redact.py +473 -7
- {pangea_sdk-6.0.0.dist-info → pangea_sdk-6.2.0b1.dist-info}/METADATA +3 -3
- {pangea_sdk-6.0.0.dist-info → pangea_sdk-6.2.0b1.dist-info}/RECORD +20 -18
- {pangea_sdk-6.0.0.dist-info → pangea_sdk-6.2.0b1.dist-info}/WHEEL +0 -0
pangea/__init__.py
CHANGED
pangea/asyncio/request.py
CHANGED
@@ -5,11 +5,12 @@ from __future__ import annotations
|
|
5
5
|
import asyncio
|
6
6
|
import json
|
7
7
|
import time
|
8
|
-
from
|
8
|
+
from collections.abc import Iterable, Mapping
|
9
|
+
from typing import Dict, List, Literal, Optional, Sequence, Tuple, Type, Union, cast, overload
|
9
10
|
|
10
11
|
import aiohttp
|
11
12
|
from aiohttp import FormData
|
12
|
-
from pydantic import BaseModel
|
13
|
+
from pydantic import BaseModel, TypeAdapter
|
13
14
|
from pydantic_core import to_jsonable_python
|
14
15
|
from typing_extensions import Any, TypeVar
|
15
16
|
|
@@ -30,6 +31,24 @@ class PangeaRequestAsync(PangeaRequestBase):
|
|
30
31
|
be set in PangeaConfig.
|
31
32
|
"""
|
32
33
|
|
34
|
+
async def delete(self, endpoint: str) -> None:
|
35
|
+
"""
|
36
|
+
Makes a DELETE call to a Pangea endpoint.
|
37
|
+
|
38
|
+
Args:
|
39
|
+
endpoint: The Pangea API endpoint.
|
40
|
+
"""
|
41
|
+
|
42
|
+
url = self._url(endpoint)
|
43
|
+
|
44
|
+
self.logger.debug(
|
45
|
+
json.dumps({"service": self.service, "action": "delete", "url": url}, default=default_encoder)
|
46
|
+
)
|
47
|
+
|
48
|
+
requests_response = await self._http_delete(url, headers=self._headers())
|
49
|
+
await self._check_http_errors(requests_response)
|
50
|
+
|
51
|
+
@overload
|
33
52
|
async def post(
|
34
53
|
self,
|
35
54
|
endpoint: str,
|
@@ -38,18 +57,60 @@ class PangeaRequestAsync(PangeaRequestBase):
|
|
38
57
|
files: Optional[List[Tuple]] = None,
|
39
58
|
poll_result: bool = True,
|
40
59
|
url: Optional[str] = None,
|
60
|
+
*,
|
61
|
+
pangea_response: Literal[True] = True,
|
41
62
|
) -> PangeaResponse[TResult]:
|
42
|
-
"""
|
63
|
+
"""
|
64
|
+
Makes a POST call to a Pangea Service endpoint.
|
43
65
|
|
44
66
|
Args:
|
45
|
-
endpoint
|
46
|
-
data
|
67
|
+
endpoint: The Pangea Service API endpoint.
|
68
|
+
data: The POST body payload object
|
47
69
|
|
48
70
|
Returns:
|
49
71
|
PangeaResponse which contains the response in its entirety and
|
50
72
|
various properties to retrieve individual fields
|
51
73
|
"""
|
52
74
|
|
75
|
+
@overload
|
76
|
+
async def post(
|
77
|
+
self,
|
78
|
+
endpoint: str,
|
79
|
+
result_class: Type[TResult],
|
80
|
+
data: str | BaseModel | dict[str, Any] | None = None,
|
81
|
+
files: Optional[List[Tuple]] = None,
|
82
|
+
poll_result: bool = True,
|
83
|
+
url: Optional[str] = None,
|
84
|
+
*,
|
85
|
+
pangea_response: Literal[False],
|
86
|
+
) -> TResult:
|
87
|
+
"""
|
88
|
+
Makes a POST call to a Pangea Service endpoint.
|
89
|
+
|
90
|
+
Args:
|
91
|
+
endpoint: The Pangea Service API endpoint.
|
92
|
+
data: The POST body payload object
|
93
|
+
"""
|
94
|
+
|
95
|
+
async def post(
|
96
|
+
self,
|
97
|
+
endpoint: str,
|
98
|
+
result_class: Type[TResult],
|
99
|
+
data: str | BaseModel | dict[str, Any] | None = None,
|
100
|
+
files: Optional[List[Tuple]] = None,
|
101
|
+
poll_result: bool = True,
|
102
|
+
url: Optional[str] = None,
|
103
|
+
*,
|
104
|
+
pangea_response: bool = True,
|
105
|
+
) -> PangeaResponse[TResult] | TResult:
|
106
|
+
"""
|
107
|
+
Makes a POST call to a Pangea Service endpoint.
|
108
|
+
|
109
|
+
Args:
|
110
|
+
endpoint: The Pangea Service API endpoint.
|
111
|
+
data: The POST body payload object
|
112
|
+
"""
|
113
|
+
|
53
114
|
if isinstance(data, BaseModel):
|
54
115
|
data = data.model_dump(exclude_none=True)
|
55
116
|
|
@@ -86,9 +147,13 @@ class PangeaRequestAsync(PangeaRequestBase):
|
|
86
147
|
|
87
148
|
await self._check_http_errors(requests_response)
|
88
149
|
|
150
|
+
if not pangea_response:
|
151
|
+
type_adapter = TypeAdapter(result_class)
|
152
|
+
return type_adapter.validate_python(await requests_response.json())
|
153
|
+
|
89
154
|
if "multipart/form-data" in requests_response.headers.get("content-type", ""):
|
90
155
|
multipart_response = await self._process_multipart_response(requests_response)
|
91
|
-
|
156
|
+
pangea_response_obj: PangeaResponse = PangeaResponse(
|
92
157
|
requests_response,
|
93
158
|
result_class=result_class,
|
94
159
|
json=multipart_response.pangea_json,
|
@@ -101,47 +166,108 @@ class PangeaRequestAsync(PangeaRequestBase):
|
|
101
166
|
json.dumps({"service": self.service, "action": "post", "url": url, "response": json_resp})
|
102
167
|
)
|
103
168
|
|
104
|
-
|
169
|
+
pangea_response_obj = PangeaResponse(requests_response, result_class=result_class, json=json_resp)
|
105
170
|
except aiohttp.ContentTypeError as e:
|
106
171
|
raise pe.PangeaException(f"Failed to decode json response. {e}. Body: {await requests_response.text()}")
|
107
172
|
|
108
173
|
if poll_result:
|
109
|
-
|
174
|
+
pangea_response_obj = await self._handle_queued_result(pangea_response_obj)
|
110
175
|
|
111
|
-
return self._check_response(
|
176
|
+
return self._check_response(pangea_response_obj)
|
112
177
|
|
113
|
-
|
114
|
-
|
178
|
+
@overload
|
179
|
+
async def get(
|
180
|
+
self,
|
181
|
+
path: str,
|
182
|
+
result_class: Type[TResult],
|
183
|
+
check_response: bool = True,
|
184
|
+
*,
|
185
|
+
params: (
|
186
|
+
Mapping[str | bytes | int | float, str | bytes | int | float | Iterable[str | bytes | int | float] | None]
|
187
|
+
| None
|
188
|
+
) = None,
|
189
|
+
pangea_response: Literal[True] = True,
|
190
|
+
) -> PangeaResponse[TResult]:
|
191
|
+
"""
|
192
|
+
Makes the GET call to a Pangea Service endpoint.
|
115
193
|
|
116
194
|
Args:
|
117
|
-
|
118
|
-
|
195
|
+
path: Additional URL path
|
196
|
+
params: Dictionary of querystring data to attach to the request
|
119
197
|
|
120
198
|
Returns:
|
121
199
|
PangeaResponse which contains the response in its entirety and
|
122
200
|
various properties to retrieve individual fields
|
123
201
|
"""
|
124
202
|
|
203
|
+
@overload
|
204
|
+
async def get(
|
205
|
+
self,
|
206
|
+
path: str,
|
207
|
+
result_class: Type[TResult],
|
208
|
+
check_response: bool = True,
|
209
|
+
*,
|
210
|
+
params: (
|
211
|
+
Mapping[str | bytes | int | float, str | bytes | int | float | Iterable[str | bytes | int | float] | None]
|
212
|
+
| None
|
213
|
+
) = None,
|
214
|
+
pangea_response: Literal[False] = False,
|
215
|
+
) -> TResult:
|
216
|
+
"""
|
217
|
+
Makes the GET call to a Pangea Service endpoint.
|
218
|
+
|
219
|
+
Args:
|
220
|
+
path: Additional URL path
|
221
|
+
params: Dictionary of querystring data to attach to the request
|
222
|
+
"""
|
223
|
+
|
224
|
+
async def get(
|
225
|
+
self,
|
226
|
+
path: str,
|
227
|
+
result_class: Type[TResult],
|
228
|
+
check_response: bool = True,
|
229
|
+
*,
|
230
|
+
params: (
|
231
|
+
Mapping[str | bytes | int | float, str | bytes | int | float | Iterable[str | bytes | int | float] | None]
|
232
|
+
| None
|
233
|
+
) = None,
|
234
|
+
pangea_response: bool = True,
|
235
|
+
) -> PangeaResponse[TResult] | TResult:
|
236
|
+
"""
|
237
|
+
Makes the GET call to a Pangea Service endpoint.
|
238
|
+
|
239
|
+
Args:
|
240
|
+
path: Additional URL path
|
241
|
+
params: Dictionary of querystring data to attach to the request
|
242
|
+
pangea_response: Whether or not the response body follows Pangea's
|
243
|
+
standard response schema
|
244
|
+
"""
|
245
|
+
|
125
246
|
url = self._url(path)
|
126
247
|
self.logger.debug(json.dumps({"service": self.service, "action": "get", "url": url}))
|
127
248
|
|
128
|
-
async with self.session.get(url, headers=self._headers()) as requests_response:
|
249
|
+
async with self.session.get(url, params=params, headers=self._headers()) as requests_response:
|
129
250
|
await self._check_http_errors(requests_response)
|
130
|
-
|
251
|
+
|
252
|
+
if not pangea_response:
|
253
|
+
type_adapter = TypeAdapter(result_class)
|
254
|
+
return type_adapter.validate_python(await requests_response.json())
|
255
|
+
|
256
|
+
pangea_response_obj = PangeaResponse(
|
131
257
|
requests_response, result_class=result_class, json=await requests_response.json()
|
132
258
|
)
|
133
259
|
|
134
260
|
self.logger.debug(
|
135
261
|
json.dumps(
|
136
|
-
{"service": self.service, "action": "get", "url": url, "response":
|
262
|
+
{"service": self.service, "action": "get", "url": url, "response": pangea_response_obj.json},
|
137
263
|
default=default_encoder,
|
138
264
|
)
|
139
265
|
)
|
140
266
|
|
141
267
|
if check_response is False:
|
142
|
-
return
|
268
|
+
return pangea_response_obj
|
143
269
|
|
144
|
-
return self._check_response(
|
270
|
+
return self._check_response(pangea_response_obj)
|
145
271
|
|
146
272
|
async def _check_http_errors(self, resp: aiohttp.ClientResponse):
|
147
273
|
if resp.status == 503:
|
@@ -275,10 +401,18 @@ class PangeaRequestAsync(PangeaRequestBase):
|
|
275
401
|
attached_files = await self._get_attached_files(multipart_reader)
|
276
402
|
return MultipartResponse(pangea_json, attached_files) # type: ignore[arg-type]
|
277
403
|
|
404
|
+
async def _http_delete(
|
405
|
+
self,
|
406
|
+
url: str,
|
407
|
+
*,
|
408
|
+
headers: Mapping[str, str | bytes | None] = {},
|
409
|
+
) -> aiohttp.ClientResponse:
|
410
|
+
return await self.session.delete(url, headers=headers)
|
411
|
+
|
278
412
|
async def _http_post(
|
279
413
|
self,
|
280
414
|
url: str,
|
281
|
-
headers:
|
415
|
+
headers: Mapping[str, str | bytes | None] = {},
|
282
416
|
data: Union[str, Dict] = {},
|
283
417
|
files: Optional[List[Tuple]] = [],
|
284
418
|
presigned_url_post: bool = False,
|
@@ -5,6 +5,7 @@ from .authz import AuthZAsync
|
|
5
5
|
from .embargo import EmbargoAsync
|
6
6
|
from .file_scan import FileScanAsync
|
7
7
|
from .intel import DomainIntelAsync, FileIntelAsync, IpIntelAsync, UrlIntelAsync, UserIntelAsync
|
8
|
+
from .management import ManagementAsync
|
8
9
|
from .prompt_guard import PromptGuardAsync
|
9
10
|
from .redact import RedactAsync
|
10
11
|
from .sanitize import SanitizeAsync
|
pangea/asyncio/services/audit.py
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
from __future__ import annotations
|
4
4
|
|
5
5
|
import datetime
|
6
|
-
from typing import Any, Dict, Iterable, List, Optional, Sequence, Union
|
6
|
+
from typing import Any, Dict, Iterable, List, Literal, Optional, Sequence, Union, cast, overload
|
7
|
+
|
8
|
+
from pydantic import TypeAdapter
|
7
9
|
|
8
10
|
import pangea.exceptions as pexc
|
9
11
|
from pangea.asyncio.services.base import ServiceBaseAsync
|
@@ -12,11 +14,13 @@ from pangea.response import PangeaResponse, PangeaResponseResult
|
|
12
14
|
from pangea.services.audit.audit import AuditBase
|
13
15
|
from pangea.services.audit.exceptions import AuditException
|
14
16
|
from pangea.services.audit.models import (
|
17
|
+
AuditSchema,
|
15
18
|
DownloadFormat,
|
16
19
|
DownloadRequest,
|
17
20
|
DownloadResult,
|
18
21
|
Event,
|
19
22
|
ExportRequest,
|
23
|
+
ForwardingConfiguration,
|
20
24
|
LogBulkResult,
|
21
25
|
LogResult,
|
22
26
|
PublishedRoot,
|
@@ -29,6 +33,9 @@ from pangea.services.audit.models import (
|
|
29
33
|
SearchRequest,
|
30
34
|
SearchResultOutput,
|
31
35
|
SearchResultRequest,
|
36
|
+
ServiceConfig,
|
37
|
+
ServiceConfigFilter,
|
38
|
+
ServiceConfigListResult,
|
32
39
|
)
|
33
40
|
from pangea.services.audit.util import format_datetime
|
34
41
|
|
@@ -590,6 +597,298 @@ class AuditAsync(ServiceBaseAsync, AuditBase):
|
|
590
597
|
)
|
591
598
|
return await self.request.post("v1/download_results", DownloadResult, data=input.model_dump(exclude_none=True))
|
592
599
|
|
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
|
+
|
593
892
|
async def update_published_roots(self, result: SearchResultOutput):
|
594
893
|
"""Fetches series of published root hashes from Arweave
|
595
894
|
|