pangea-sdk 6.2.0b2__tar.gz → 6.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. pangea_sdk-6.2.0b2/README.md → pangea_sdk-6.3.0/PKG-INFO +50 -7
  2. pangea_sdk-6.2.0b2/PKG-INFO → pangea_sdk-6.3.0/README.md +27 -32
  3. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/__init__.py +1 -1
  4. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/asyncio/request.py +25 -154
  5. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/asyncio/services/__init__.py +0 -1
  6. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/asyncio/services/ai_guard.py +9 -101
  7. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/asyncio/services/audit.py +1 -301
  8. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/asyncio/services/authn.py +7 -9
  9. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/asyncio/services/authz.py +45 -11
  10. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/asyncio/services/intel.py +20 -26
  11. pangea_sdk-6.3.0/pangea/asyncio/services/prompt_guard.py +84 -0
  12. pangea_sdk-6.3.0/pangea/asyncio/services/redact.py +206 -0
  13. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/asyncio/services/vault.py +52 -40
  14. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/request.py +30 -167
  15. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/response.py +6 -6
  16. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/__init__.py +0 -1
  17. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/ai_guard.py +20 -490
  18. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/audit/audit.py +2 -301
  19. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/audit/models.py +65 -307
  20. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/authn/authn.py +6 -8
  21. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/authn/models.py +183 -151
  22. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/authz.py +101 -57
  23. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/base.py +2 -3
  24. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/intel.py +32 -19
  25. pangea_sdk-6.3.0/pangea/services/prompt_guard.py +118 -0
  26. pangea_sdk-6.3.0/pangea/services/redact.py +388 -0
  27. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/vault/models/common.py +11 -12
  28. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/vault/models/keys.py +4 -9
  29. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/vault/models/secret.py +3 -8
  30. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/vault/vault.py +52 -40
  31. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pyproject.toml +10 -10
  32. pangea_sdk-6.2.0b2/pangea/asyncio/services/management.py +0 -576
  33. pangea_sdk-6.2.0b2/pangea/asyncio/services/prompt_guard.py +0 -194
  34. pangea_sdk-6.2.0b2/pangea/asyncio/services/redact.py +0 -467
  35. pangea_sdk-6.2.0b2/pangea/services/management.py +0 -720
  36. pangea_sdk-6.2.0b2/pangea/services/prompt_guard.py +0 -309
  37. pangea_sdk-6.2.0b2/pangea/services/redact.py +0 -854
  38. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/asyncio/__init__.py +0 -0
  39. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/asyncio/file_uploader.py +0 -0
  40. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/asyncio/services/base.py +0 -0
  41. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/asyncio/services/embargo.py +0 -0
  42. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/asyncio/services/file_scan.py +0 -0
  43. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/asyncio/services/sanitize.py +0 -0
  44. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/asyncio/services/share.py +0 -0
  45. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/audit_logger.py +0 -0
  46. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/config.py +0 -0
  47. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/crypto/rsa.py +0 -0
  48. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/deep_verify.py +0 -0
  49. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/deprecated.py +0 -0
  50. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/dump_audit.py +0 -0
  51. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/exceptions.py +0 -0
  52. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/file_uploader.py +0 -0
  53. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/py.typed +0 -0
  54. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/audit/exceptions.py +0 -0
  55. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/audit/signing.py +0 -0
  56. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/audit/util.py +0 -0
  57. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/embargo.py +0 -0
  58. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/file_scan.py +0 -0
  59. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/sanitize.py +0 -0
  60. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/share/file_format.py +0 -0
  61. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/share/share.py +0 -0
  62. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/vault/models/asymmetric.py +0 -0
  63. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/services/vault/models/symmetric.py +0 -0
  64. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/tools.py +0 -0
  65. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/utils.py +0 -0
  66. {pangea_sdk-6.2.0b2 → pangea_sdk-6.3.0}/pangea/verify_audit.py +0 -0
@@ -1,3 +1,26 @@
1
+ Metadata-Version: 2.3
2
+ Name: pangea-sdk
3
+ Version: 6.3.0
4
+ Summary: Pangea API SDK
5
+ License: MIT
6
+ Keywords: Pangea,SDK,Audit
7
+ Author: Glenn Gallien
8
+ Author-email: glenn.gallien@pangea.cloud
9
+ Requires-Python: >=3.9.2,<4.0.0
10
+ Classifier: Topic :: Software Development
11
+ Classifier: Topic :: Software Development :: Libraries
12
+ Requires-Dist: aiohttp (>=3.12.14,<4.0.0)
13
+ Requires-Dist: cryptography (>=45.0.5,<46.0.0)
14
+ Requires-Dist: deprecated (>=1.2.18,<2.0.0)
15
+ Requires-Dist: google-crc32c (>=1.7.1,<2.0.0)
16
+ Requires-Dist: pydantic (>=2.11.7,<3.0.0)
17
+ Requires-Dist: python-dateutil (>=2.9.0.post0,<3.0.0)
18
+ Requires-Dist: requests (>=2.32.4,<3.0.0)
19
+ Requires-Dist: requests-toolbelt (>=1.0.0,<2.0.0)
20
+ Requires-Dist: typing-extensions (>=4.14.1,<5.0.0)
21
+ Requires-Dist: yarl (>=1.20.1,<2.0.0)
22
+ Description-Content-Type: text/markdown
23
+
1
24
  <a href="https://pangea.cloud?utm_source=github&utm_medium=python-sdk" target="_blank" rel="noopener noreferrer">
2
25
  <img src="https://pangea-marketing.s3.us-west-2.amazonaws.com/pangea-color.svg" alt="Pangea Logo" height="40" />
3
26
  </a>
@@ -79,6 +102,26 @@ audit = Audit(token, config)
79
102
  response = audit.log(message="Hello, World!")
80
103
  ```
81
104
 
105
+ ## Configuration
106
+
107
+ The SDK supports the following configuration options via `PangeaConfig`:
108
+
109
+ - `base_url_template` — Template for constructing the base URL for API requests.
110
+ The placeholder `{SERVICE_NAME}` will be replaced with the service name slug.
111
+ This is a more powerful version of `domain` that allows for setting more than
112
+ just the host of the API server. Defaults to
113
+ `https://{SERVICE_NAME}.aws.us.pangea.cloud`.
114
+ - `domain` — Base domain for API requests. This is a weaker version of
115
+ `base_url_template` that only allows for setting the host of the API server.
116
+ Use `base_url_template` for more control over the URL, such as setting
117
+ service-specific paths. Defaults to `aws.us.pangea.cloud`.
118
+ - `request_retries` — Number of retries on the initial request.
119
+ - `request_backoff` — Backoff strategy passed to 'requests'.
120
+ - `request_timeout` — Timeout used on initial request attempts.
121
+ - `poll_result_timeout` — Timeout used to poll results after 202 (in secs).
122
+ - `queued_retry_enabled` — Enable queued request retry support.
123
+ - `custom_user_agent` — Custom user agent to be used in the request headers.
124
+
82
125
  ## asyncio support
83
126
 
84
127
  asyncio support is available through the `pangea.asyncio.services` module. The
@@ -133,6 +176,7 @@ options:
133
176
  ```
134
177
 
135
178
  It accepts multiple file formats:
179
+
136
180
  - a Verification Artifact from the Pangea User Console
137
181
  - a search response from the REST API:
138
182
 
@@ -140,7 +184,6 @@ It accepts multiple file formats:
140
184
  $ curl -H "Authorization: Bearer ${PANGEA_TOKEN}" -X POST -H 'Content-Type: application/json' --data '{"verbose": true}' https://audit.aws.us.pangea.cloud/v1/search
141
185
  ```
142
186
 
143
-
144
187
  ### Bulk Download Audit Data
145
188
 
146
189
  Download all audit logs for a given time range. Start and end date should be provided,
@@ -190,14 +233,14 @@ options:
190
233
  ```
191
234
 
192
235
  It accepts multiple file formats:
236
+
193
237
  - a Verification Artifact from the Pangea User Console
194
238
  - a file generated by the `dump_audit` command
195
239
  - a search response from the REST API (see `verify_audit`)
196
240
 
241
+ [Documentation]: https://pangea.cloud/docs/sdk/python/
242
+ [GA Examples]: https://github.com/pangeacyber/pangea-python/tree/main/examples
243
+ [Beta Examples]: https://github.com/pangeacyber/pangea-python/tree/beta/examples
244
+ [Pangea Console]: https://console.pangea.cloud/
245
+ [Secure Audit Log]: https://pangea.cloud/docs/audit
197
246
 
198
-
199
- [Documentation]: https://pangea.cloud/docs/sdk/python/
200
- [GA Examples]: https://github.com/pangeacyber/pangea-python/tree/main/examples
201
- [Beta Examples]: https://github.com/pangeacyber/pangea-python/tree/beta/examples
202
- [Pangea Console]: https://console.pangea.cloud/
203
- [Secure Audit Log]: https://pangea.cloud/docs/audit
@@ -1,26 +1,3 @@
1
- Metadata-Version: 2.3
2
- Name: pangea-sdk
3
- Version: 6.2.0b2
4
- Summary: Pangea API SDK
5
- License: MIT
6
- Keywords: Pangea,SDK,Audit
7
- Author: Glenn Gallien
8
- Author-email: glenn.gallien@pangea.cloud
9
- Requires-Python: >=3.9.2,<4.0.0
10
- Classifier: Topic :: Software Development
11
- Classifier: Topic :: Software Development :: Libraries
12
- Requires-Dist: aiohttp (>=3.11.18,<4.0.0)
13
- Requires-Dist: cryptography (>=45.0.2,<46.0.0)
14
- Requires-Dist: deprecated (>=1.2.18,<2.0.0)
15
- Requires-Dist: google-crc32c (>=1.7.1,<2.0.0)
16
- Requires-Dist: pydantic (>=2.11.4,<3.0.0)
17
- Requires-Dist: python-dateutil (>=2.9.0.post0,<3.0.0)
18
- Requires-Dist: requests (>=2.32.3,<3.0.0)
19
- Requires-Dist: requests-toolbelt (>=1.0.0,<2.0.0)
20
- Requires-Dist: typing-extensions (>=4.13.2,<5.0.0)
21
- Requires-Dist: yarl (>=1.20.0,<2.0.0)
22
- Description-Content-Type: text/markdown
23
-
24
1
  <a href="https://pangea.cloud?utm_source=github&utm_medium=python-sdk" target="_blank" rel="noopener noreferrer">
25
2
  <img src="https://pangea-marketing.s3.us-west-2.amazonaws.com/pangea-color.svg" alt="Pangea Logo" height="40" />
26
3
  </a>
@@ -102,6 +79,26 @@ audit = Audit(token, config)
102
79
  response = audit.log(message="Hello, World!")
103
80
  ```
104
81
 
82
+ ## Configuration
83
+
84
+ The SDK supports the following configuration options via `PangeaConfig`:
85
+
86
+ - `base_url_template` — Template for constructing the base URL for API requests.
87
+ The placeholder `{SERVICE_NAME}` will be replaced with the service name slug.
88
+ This is a more powerful version of `domain` that allows for setting more than
89
+ just the host of the API server. Defaults to
90
+ `https://{SERVICE_NAME}.aws.us.pangea.cloud`.
91
+ - `domain` — Base domain for API requests. This is a weaker version of
92
+ `base_url_template` that only allows for setting the host of the API server.
93
+ Use `base_url_template` for more control over the URL, such as setting
94
+ service-specific paths. Defaults to `aws.us.pangea.cloud`.
95
+ - `request_retries` — Number of retries on the initial request.
96
+ - `request_backoff` — Backoff strategy passed to 'requests'.
97
+ - `request_timeout` — Timeout used on initial request attempts.
98
+ - `poll_result_timeout` — Timeout used to poll results after 202 (in secs).
99
+ - `queued_retry_enabled` — Enable queued request retry support.
100
+ - `custom_user_agent` — Custom user agent to be used in the request headers.
101
+
105
102
  ## asyncio support
106
103
 
107
104
  asyncio support is available through the `pangea.asyncio.services` module. The
@@ -156,6 +153,7 @@ options:
156
153
  ```
157
154
 
158
155
  It accepts multiple file formats:
156
+
159
157
  - a Verification Artifact from the Pangea User Console
160
158
  - a search response from the REST API:
161
159
 
@@ -163,7 +161,6 @@ It accepts multiple file formats:
163
161
  $ curl -H "Authorization: Bearer ${PANGEA_TOKEN}" -X POST -H 'Content-Type: application/json' --data '{"verbose": true}' https://audit.aws.us.pangea.cloud/v1/search
164
162
  ```
165
163
 
166
-
167
164
  ### Bulk Download Audit Data
168
165
 
169
166
  Download all audit logs for a given time range. Start and end date should be provided,
@@ -213,15 +210,13 @@ options:
213
210
  ```
214
211
 
215
212
  It accepts multiple file formats:
213
+
216
214
  - a Verification Artifact from the Pangea User Console
217
215
  - a file generated by the `dump_audit` command
218
216
  - a search response from the REST API (see `verify_audit`)
219
217
 
220
-
221
-
222
- [Documentation]: https://pangea.cloud/docs/sdk/python/
223
- [GA Examples]: https://github.com/pangeacyber/pangea-python/tree/main/examples
224
- [Beta Examples]: https://github.com/pangeacyber/pangea-python/tree/beta/examples
225
- [Pangea Console]: https://console.pangea.cloud/
226
- [Secure Audit Log]: https://pangea.cloud/docs/audit
227
-
218
+ [Documentation]: https://pangea.cloud/docs/sdk/python/
219
+ [GA Examples]: https://github.com/pangeacyber/pangea-python/tree/main/examples
220
+ [Beta Examples]: https://github.com/pangeacyber/pangea-python/tree/beta/examples
221
+ [Pangea Console]: https://console.pangea.cloud/
222
+ [Secure Audit Log]: https://pangea.cloud/docs/audit
@@ -1,4 +1,4 @@
1
- __version__ = "6.2.0beta2"
1
+ __version__ = "6.3.0"
2
2
 
3
3
  from pangea.asyncio.request import PangeaRequestAsync
4
4
  from pangea.config import PangeaConfig
@@ -10,13 +10,13 @@ import asyncio
10
10
  import json
11
11
  import time
12
12
  from collections.abc import Iterable, Mapping
13
- from typing import Dict, List, Optional, Sequence, Tuple, Type, Union, cast, overload
13
+ from typing import Dict, List, Optional, Sequence, Tuple, Type, Union, cast
14
14
 
15
15
  import aiohttp
16
16
  from aiohttp import FormData
17
- from pydantic import BaseModel, TypeAdapter
17
+ from pydantic import BaseModel
18
18
  from pydantic_core import to_jsonable_python
19
- from typing_extensions import Any, Literal, TypeAlias, TypeVar, override
19
+ from typing_extensions import Any, TypeAlias, TypeVar, override
20
20
 
21
21
  import pangea.exceptions as pe
22
22
  from pangea.request import MultipartResponse, PangeaRequestBase
@@ -32,6 +32,10 @@ _FileSpecTuple3: TypeAlias = tuple[_FileName, _FileContent, _FileContentType]
32
32
  _FileSpecTuple4: TypeAlias = tuple[_FileName, _FileContent, _FileContentType, _FileCustomHeaders]
33
33
  _FileSpec: TypeAlias = Union[_FileContent, _FileSpecTuple2, _FileSpecTuple3, _FileSpecTuple4]
34
34
  _Files: TypeAlias = Union[Mapping[str, _FileSpec], Iterable[tuple[str, _FileSpec]]]
35
+ _LooseHeaders = Union[
36
+ Mapping[str, str],
37
+ Iterable[tuple[str, str]],
38
+ ]
35
39
 
36
40
 
37
41
  TResult = TypeVar("TResult", bound=PangeaResponseResult)
@@ -46,24 +50,6 @@ class PangeaRequestAsync(PangeaRequestBase):
46
50
  be set in PangeaConfig.
47
51
  """
48
52
 
49
- async def delete(self, endpoint: str) -> None:
50
- """
51
- Makes a DELETE call to a Pangea endpoint.
52
-
53
- Args:
54
- endpoint: The Pangea API endpoint.
55
- """
56
-
57
- url = self._url(endpoint)
58
-
59
- self.logger.debug(
60
- json.dumps({"service": self.service, "action": "delete", "url": url}, default=default_encoder)
61
- )
62
-
63
- requests_response = await self._http_delete(url, headers=self._headers())
64
- await self._check_http_errors(requests_response)
65
-
66
- @overload
67
53
  async def post(
68
54
  self,
69
55
  endpoint: str,
@@ -72,60 +58,18 @@ class PangeaRequestAsync(PangeaRequestBase):
72
58
  files: Optional[List[Tuple]] = None,
73
59
  poll_result: bool = True,
74
60
  url: Optional[str] = None,
75
- *,
76
- pangea_response: Literal[True] = True,
77
61
  ) -> PangeaResponse[TResult]:
78
- """
79
- Makes a POST call to a Pangea Service endpoint.
62
+ """Makes the POST call to a Pangea Service endpoint.
80
63
 
81
64
  Args:
82
- endpoint: The Pangea Service API endpoint.
83
- data: The POST body payload object
65
+ endpoint(str): The Pangea Service API endpoint.
66
+ data(dict): The POST body payload object
84
67
 
85
68
  Returns:
86
69
  PangeaResponse which contains the response in its entirety and
87
70
  various properties to retrieve individual fields
88
71
  """
89
72
 
90
- @overload
91
- async def post(
92
- self,
93
- endpoint: str,
94
- result_class: Type[TResult],
95
- data: str | BaseModel | Mapping[str, Any] | None = None,
96
- files: Optional[List[Tuple]] = None,
97
- poll_result: bool = True,
98
- url: Optional[str] = None,
99
- *,
100
- pangea_response: Literal[False],
101
- ) -> TResult:
102
- """
103
- Makes a POST call to a Pangea Service endpoint.
104
-
105
- Args:
106
- endpoint: The Pangea Service API endpoint.
107
- data: The POST body payload object
108
- """
109
-
110
- async def post(
111
- self,
112
- endpoint: str,
113
- result_class: Type[TResult],
114
- data: str | BaseModel | Mapping[str, Any] | None = None,
115
- files: Optional[List[Tuple]] = None,
116
- poll_result: bool = True,
117
- url: Optional[str] = None,
118
- *,
119
- pangea_response: bool = True,
120
- ) -> PangeaResponse[TResult] | TResult:
121
- """
122
- Makes a POST call to a Pangea Service endpoint.
123
-
124
- Args:
125
- endpoint: The Pangea Service API endpoint.
126
- data: The POST body payload object
127
- """
128
-
129
73
  if isinstance(data, BaseModel):
130
74
  data = data.model_dump(exclude_none=True)
131
75
 
@@ -165,13 +109,9 @@ class PangeaRequestAsync(PangeaRequestBase):
165
109
 
166
110
  await self._check_http_errors(requests_response)
167
111
 
168
- if not pangea_response:
169
- type_adapter = TypeAdapter(result_class)
170
- return type_adapter.validate_python(await requests_response.json())
171
-
172
112
  if "multipart/form-data" in requests_response.headers.get("content-type", ""):
173
113
  multipart_response = await self._process_multipart_response(requests_response)
174
- pangea_response_obj: PangeaResponse = PangeaResponse(
114
+ pangea_response: PangeaResponse = PangeaResponse(
175
115
  requests_response,
176
116
  result_class=result_class,
177
117
  json=multipart_response.pangea_json,
@@ -184,110 +124,49 @@ class PangeaRequestAsync(PangeaRequestBase):
184
124
  json.dumps({"service": self.service, "action": "post", "url": url, "response": json_resp})
185
125
  )
186
126
 
187
- pangea_response_obj = PangeaResponse(requests_response, result_class=result_class, json=json_resp)
127
+ pangea_response = PangeaResponse(requests_response, result_class=result_class, json=json_resp)
188
128
  except aiohttp.ContentTypeError as e:
189
129
  raise pe.PangeaException(
190
130
  f"Failed to decode json response. {e}. Body: {await requests_response.text()}"
191
131
  ) from e
192
132
 
193
133
  if poll_result:
194
- pangea_response_obj = await self._handle_queued_result(pangea_response_obj)
134
+ pangea_response = await self._handle_queued_result(pangea_response)
195
135
 
196
- return self._check_response(pangea_response_obj)
136
+ return self._check_response(pangea_response)
197
137
 
198
- @overload
199
- async def get(
200
- self,
201
- path: str,
202
- result_class: Type[TResult],
203
- check_response: bool = True,
204
- *,
205
- params: (
206
- Mapping[str | bytes | int | float, str | bytes | int | float | Iterable[str | bytes | int | float] | None]
207
- | None
208
- ) = None,
209
- pangea_response: Literal[True] = True,
210
- ) -> PangeaResponse[TResult]:
211
- """
212
- Makes the GET call to a Pangea Service endpoint.
138
+ async def get(self, path: str, result_class: Type[TResult], check_response: bool = True) -> PangeaResponse[TResult]:
139
+ """Makes the GET call to a Pangea Service endpoint.
213
140
 
214
141
  Args:
215
- path: Additional URL path
216
- params: Dictionary of querystring data to attach to the request
142
+ endpoint(str): The Pangea Service API endpoint.
143
+ path(str): Additional URL path
217
144
 
218
145
  Returns:
219
146
  PangeaResponse which contains the response in its entirety and
220
147
  various properties to retrieve individual fields
221
148
  """
222
149
 
223
- @overload
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: Literal[False] = False,
235
- ) -> 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
- """
243
-
244
- async def get(
245
- self,
246
- path: str,
247
- result_class: Type[TResult],
248
- check_response: bool = True,
249
- *,
250
- params: (
251
- Mapping[str | bytes | int | float, str | bytes | int | float | Iterable[str | bytes | int | float] | None]
252
- | None
253
- ) = None,
254
- pangea_response: bool = True,
255
- ) -> PangeaResponse[TResult] | TResult:
256
- """
257
- Makes the GET call to a Pangea Service endpoint.
258
-
259
- Args:
260
- path: Additional URL path
261
- params: Dictionary of querystring data to attach to the request
262
- pangea_response: Whether or not the response body follows Pangea's
263
- standard response schema
264
- """
265
-
266
150
  url = self._url(path)
267
151
  self.logger.debug(json.dumps({"service": self.service, "action": "get", "url": url}))
268
152
 
269
- async with self.session.get(url, params=params, headers=self._headers()) as requests_response:
153
+ async with self.session.get(url, headers=self._headers()) as requests_response:
270
154
  await self._check_http_errors(requests_response)
271
-
272
- if not pangea_response:
273
- type_adapter = TypeAdapter(result_class)
274
- return type_adapter.validate_python(await requests_response.json())
275
-
276
- pangea_response_obj = PangeaResponse(
155
+ pangea_response = PangeaResponse(
277
156
  requests_response, result_class=result_class, json=await requests_response.json()
278
157
  )
279
158
 
280
159
  self.logger.debug(
281
160
  json.dumps(
282
- {"service": self.service, "action": "get", "url": url, "response": pangea_response_obj.json},
161
+ {"service": self.service, "action": "get", "url": url, "response": pangea_response.json},
283
162
  default=default_encoder,
284
163
  )
285
164
  )
286
165
 
287
166
  if check_response is False:
288
- return pangea_response_obj
167
+ return pangea_response
289
168
 
290
- return self._check_response(pangea_response_obj)
169
+ return self._check_response(pangea_response)
291
170
 
292
171
  async def _check_http_errors(self, resp: aiohttp.ClientResponse):
293
172
  if resp.status == 503:
@@ -421,18 +300,10 @@ class PangeaRequestAsync(PangeaRequestBase):
421
300
  attached_files = await self._get_attached_files(multipart_reader)
422
301
  return MultipartResponse(pangea_json, attached_files) # type: ignore[arg-type]
423
302
 
424
- async def _http_delete(
425
- self,
426
- url: str,
427
- *,
428
- headers: Mapping[str, str | bytes | None] = {},
429
- ) -> aiohttp.ClientResponse:
430
- return await self.session.delete(url, headers=headers)
431
-
432
303
  async def _http_post(
433
304
  self,
434
305
  url: str,
435
- headers: Mapping[str, str] = {},
306
+ headers: _LooseHeaders = {}, # noqa: B006
436
307
  data: str | dict[str, Any] | None = None,
437
308
  files: _Files | None = None,
438
309
  presigned_url_post: bool = False,
@@ -469,7 +340,7 @@ class PangeaRequestAsync(PangeaRequestBase):
469
340
  self,
470
341
  url: str,
471
342
  files: Sequence[Tuple],
472
- headers: Mapping[str, str] = {},
343
+ headers: _LooseHeaders = {}, # noqa: B006
473
344
  ) -> aiohttp.ClientResponse:
474
345
  self.logger.debug(
475
346
  json.dumps({"service": self.service, "action": "http_put", "url": url}, default=default_encoder)
@@ -7,7 +7,6 @@ from .authz import AuthZAsync
7
7
  from .embargo import EmbargoAsync
8
8
  from .file_scan import FileScanAsync
9
9
  from .intel import DomainIntelAsync, FileIntelAsync, IpIntelAsync, UrlIntelAsync, UserIntelAsync
10
- from .management import ManagementAsync
11
10
  from .prompt_guard import PromptGuardAsync
12
11
  from .redact import RedactAsync
13
12
  from .sanitize import SanitizeAsync
@@ -1,26 +1,12 @@
1
1
  from __future__ import annotations
2
2
 
3
- from collections.abc import Mapping
3
+ from collections.abc import Sequence
4
4
  from typing import overload
5
5
 
6
- from typing_extensions import Literal, TypeVar
7
-
8
6
  from pangea.asyncio.services.base import ServiceBaseAsync
9
7
  from pangea.config import PangeaConfig
10
8
  from pangea.response import PangeaResponse
11
- from pangea.services.ai_guard import (
12
- AuditDataActivityConfig,
13
- ConnectionsConfig,
14
- LogFields,
15
- Overrides,
16
- RecipeConfig,
17
- ServiceConfig,
18
- ServiceConfigFilter,
19
- ServiceConfigsPage,
20
- TextGuardResult,
21
- )
22
-
23
- _T = TypeVar("_T")
9
+ from pangea.services.ai_guard import LogFields, Message, Overrides, TextGuardResult
24
10
 
25
11
 
26
12
  class AIGuardAsync(ServiceBaseAsync):
@@ -71,7 +57,7 @@ class AIGuardAsync(ServiceBaseAsync):
71
57
  debug: bool | None = None,
72
58
  overrides: Overrides | None = None,
73
59
  log_fields: LogFields | None = None,
74
- ) -> PangeaResponse[TextGuardResult[None]]:
60
+ ) -> PangeaResponse[TextGuardResult]:
75
61
  """
76
62
  Text Guard for scanning LLM inputs and outputs
77
63
 
@@ -99,12 +85,12 @@ class AIGuardAsync(ServiceBaseAsync):
99
85
  async def guard_text(
100
86
  self,
101
87
  *,
102
- messages: _T,
88
+ messages: Sequence[Message],
103
89
  recipe: str | None = None,
104
90
  debug: bool | None = None,
105
91
  overrides: Overrides | None = None,
106
92
  log_fields: LogFields | None = None,
107
- ) -> PangeaResponse[TextGuardResult[_T]]:
93
+ ) -> PangeaResponse[TextGuardResult]:
108
94
  """
109
95
  Text Guard for scanning LLM inputs and outputs
110
96
 
@@ -126,19 +112,19 @@ class AIGuardAsync(ServiceBaseAsync):
126
112
  log_field: Additional fields to include in activity log
127
113
 
128
114
  Examples:
129
- response = await ai_guard.guard_text(messages=[{"role": "user", "content": "hello world"}])
115
+ response = await ai_guard.guard_text(messages=[Message(role="user", content="hello world")])
130
116
  """
131
117
 
132
- async def guard_text( # type: ignore[misc]
118
+ async def guard_text(
133
119
  self,
134
120
  text: str | None = None,
135
121
  *,
136
- messages: _T | None = None,
122
+ messages: Sequence[Message] | None = None,
137
123
  recipe: str | None = None,
138
124
  debug: bool | None = None,
139
125
  overrides: Overrides | None = None,
140
126
  log_fields: LogFields | None = None,
141
- ) -> PangeaResponse[TextGuardResult[None]]:
127
+ ) -> PangeaResponse[TextGuardResult]:
142
128
  """
143
129
  Text Guard for scanning LLM inputs and outputs
144
130
 
@@ -181,81 +167,3 @@ class AIGuardAsync(ServiceBaseAsync):
181
167
  "log_fields": log_fields,
182
168
  },
183
169
  )
184
-
185
- async def get_service_config(self, id: str) -> PangeaResponse[ServiceConfig]:
186
- """
187
- OperationId: ai_guard_post_v1beta_config
188
- """
189
- return await self.request.post("v1beta/config", data={"id": id}, result_class=ServiceConfig)
190
-
191
- async def create_service_config(
192
- self,
193
- name: str,
194
- *,
195
- id: str | None = None,
196
- audit_data_activity: AuditDataActivityConfig | None = None,
197
- connections: ConnectionsConfig | None = None,
198
- recipes: Mapping[str, RecipeConfig] | None = None,
199
- ) -> PangeaResponse[ServiceConfig]:
200
- """
201
- OperationId: ai_guard_post_v1beta_config_create
202
- """
203
- return await self.request.post(
204
- "v1beta/config/create",
205
- data={
206
- "name": name,
207
- "id": id,
208
- "audit_data_activity": audit_data_activity,
209
- "connections": connections,
210
- "recipes": recipes,
211
- },
212
- result_class=ServiceConfig,
213
- )
214
-
215
- async def update_service_config(
216
- self,
217
- id: str,
218
- name: str,
219
- *,
220
- audit_data_activity: AuditDataActivityConfig | None = None,
221
- connections: ConnectionsConfig | None = None,
222
- recipes: Mapping[str, RecipeConfig] | None = None,
223
- ) -> PangeaResponse[ServiceConfig]:
224
- """
225
- OperationId: ai_guard_post_v1beta_config_update
226
- """
227
- return await self.request.post(
228
- "v1beta/config/update",
229
- data={
230
- "id": id,
231
- "name": name,
232
- "audit_data_activity": audit_data_activity,
233
- "connections": connections,
234
- "recipes": recipes,
235
- },
236
- result_class=ServiceConfig,
237
- )
238
-
239
- async def delete_service_config(self, id: str) -> PangeaResponse[ServiceConfig]:
240
- """
241
- OperationId: ai_guard_post_v1beta_config_delete
242
- """
243
- return await self.request.post("v1beta/config/delete", data={"id": id}, result_class=ServiceConfig)
244
-
245
- async def list_service_configs(
246
- self,
247
- *,
248
- filter: ServiceConfigFilter | None = None,
249
- last: str | None = None,
250
- order: Literal["asc", "desc"] | None = None,
251
- order_by: Literal["id", "created_at", "updated_at"] | None = None,
252
- size: int | None = None,
253
- ) -> PangeaResponse[ServiceConfigsPage]:
254
- """
255
- OperationId: ai_guard_post_v1beta_config_list
256
- """
257
- return await self.request.post(
258
- "v1beta/config/list",
259
- data={"filter": filter, "last": last, "order": order, "order_by": order_by, "size": size},
260
- result_class=ServiceConfigsPage,
261
- )