external-systems 0.104.0rc1__tar.gz → 0.106.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.

Potentially problematic release.


This version of external-systems might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: external-systems
3
- Version: 0.104.0rc1
3
+ Version: 0.106.0
4
4
  Summary: A Python library for interacting with Foundry Sources
5
5
  License: Apache-2.0
6
6
  Keywords: Palantir,Foundry,Sources,Compute Modules,Python Functions,Transforms
@@ -72,18 +72,21 @@ my_source: Source = ...
72
72
  some_secret: str = my_source.get_secret("SECRET_NAME")
73
73
  ```
74
74
 
75
- For sources using session credentials we support credentials generation and refresh management. Currently on an S3 source you can access session credentials using `get_aws_credentials()`. This method will throw if the source is not pre-configured with `AwsCredentials`
75
+ For sources using session credentials we support credentials generation and refresh management. This can be done by using `get_session_credentials` which supports `S3`, `BigQuery`, `Google Cloud Storage` sources.
76
76
 
77
77
  _Session credentials may not be available in all Foundry runtime environments_
78
78
 
79
79
  ```python
80
- from external_systems.sources import Source, Refreshable, AwsCredentials
80
+ from external_systems.sources import Source, Refreshable, SourceCredentials, AwsCredentials
81
81
 
82
82
  s3_source: Source = ...
83
83
 
84
- refreshable_credentials: Refreshable[AwsCredentials] = s3_source.get_aws_credentials()
84
+ refreshable_credentials: Refreshable[SourceCredentials] = s3_source.get_session_credentials()
85
85
 
86
- session_credentials: AwsCredentials = refreshable_credentials.get()
86
+ session_credentials: SourceCredentials = refreshable_credentials.get()
87
+
88
+ if not isinstance(session_credentials, AwsCredentials):
89
+ raise ...
87
90
  ```
88
91
 
89
92
  ## On-prem Connectivity with [Foundry Agent Proxy](https://www.palantir.com/docs/foundry/data-connection/agent-proxy-runtime)
@@ -52,18 +52,21 @@ my_source: Source = ...
52
52
  some_secret: str = my_source.get_secret("SECRET_NAME")
53
53
  ```
54
54
 
55
- For sources using session credentials we support credentials generation and refresh management. Currently on an S3 source you can access session credentials using `get_aws_credentials()`. This method will throw if the source is not pre-configured with `AwsCredentials`
55
+ For sources using session credentials we support credentials generation and refresh management. This can be done by using `get_session_credentials` which supports `S3`, `BigQuery`, `Google Cloud Storage` sources.
56
56
 
57
57
  _Session credentials may not be available in all Foundry runtime environments_
58
58
 
59
59
  ```python
60
- from external_systems.sources import Source, Refreshable, AwsCredentials
60
+ from external_systems.sources import Source, Refreshable, SourceCredentials, AwsCredentials
61
61
 
62
62
  s3_source: Source = ...
63
63
 
64
- refreshable_credentials: Refreshable[AwsCredentials] = s3_source.get_aws_credentials()
64
+ refreshable_credentials: Refreshable[SourceCredentials] = s3_source.get_session_credentials()
65
65
 
66
- session_credentials: AwsCredentials = refreshable_credentials.get()
66
+ session_credentials: SourceCredentials = refreshable_credentials.get()
67
+
68
+ if not isinstance(session_credentials, AwsCredentials):
69
+ raise ...
67
70
  ```
68
71
 
69
72
  ## On-prem Connectivity with [Foundry Agent Proxy](https://www.palantir.com/docs/foundry/data-connection/agent-proxy-runtime)
@@ -16,4 +16,4 @@
16
16
  # The version is set during the publishing step (since we can't know the version in advance)
17
17
  # using the autorelease bot
18
18
 
19
- __version__ = "0.104.0-rc1"
19
+ __version__ = "0.106.0"
@@ -16,6 +16,7 @@ from ._api import (
16
16
  AwsCredentials,
17
17
  ClientCertificate,
18
18
  ClientCertificateFilePaths,
19
+ GcpOauthCredentials,
19
20
  HttpsConnectionParameters,
20
21
  SourceCredentials,
21
22
  SourceParameters,
@@ -27,6 +28,7 @@ from ._sources import Source
27
28
  __all__ = [
28
29
  "ClientCertificate",
29
30
  "ClientCertificateFilePaths",
31
+ "GcpOauthCredentials",
30
32
  "HttpsConnection",
31
33
  "HttpsConnectionParameters",
32
34
  "Source",
@@ -66,8 +66,14 @@ class AwsCredentials:
66
66
  expiration: Optional[datetime] = None
67
67
 
68
68
 
69
+ @dataclass(frozen=True)
70
+ class GcpOauthCredentials:
71
+ access_token: str
72
+ expiration: Optional[datetime] = None
73
+
74
+
69
75
  # Each new credential type must include an expiration field
70
- SourceCredentials = Union[AwsCredentials]
76
+ SourceCredentials = Union[AwsCredentials, GcpOauthCredentials]
71
77
 
72
78
 
73
79
  @dataclass(frozen=True)
@@ -16,9 +16,10 @@ import logging
16
16
  import os
17
17
  import random
18
18
  import socket
19
+ import warnings
19
20
  from functools import cached_property
20
21
  from tempfile import NamedTemporaryFile
21
- from typing import Any, Mapping, Optional, Tuple
22
+ from typing import Any, Mapping, Optional, Tuple, cast
22
23
 
23
24
  import urllib3.util
24
25
  from frozendict import frozendict
@@ -75,13 +76,20 @@ class Source:
75
76
  def _https_connections(self) -> Mapping[str, HttpsConnection]:
76
77
  return frozendict(
77
78
  {
78
- key: HttpsConnection(params, self._client_certificate, self._https_proxy_url, self._ca_bundle_path)
79
+ key: HttpsConnection(
80
+ params, self._client_certificate, self._https_proxy_url, self.server_certificates_bundle_path
81
+ )
79
82
  for key, params in self._source_parameters.https_connections.items()
80
83
  }
81
84
  )
82
85
 
83
- @cached_property
84
- def _ca_bundle_path(self) -> Optional[str]:
86
+ @property
87
+ def server_certificates_bundle_path(self) -> Optional[str]:
88
+ """
89
+ File path to the CA bundle file containing all server certificates required by the Source.
90
+ If no server certificates are defined on the Source, this will return None.
91
+ """
92
+
85
93
  if self._source_parameters.server_certificates is None:
86
94
  return None
87
95
 
@@ -185,15 +193,29 @@ class Source:
185
193
 
186
194
  def get_aws_credentials(self) -> Refreshable[AwsCredentials]:
187
195
  """
188
- Get the AWS credentials from the Source.
196
+ DEPRECATED: Use get_session_credentials instead.
197
+ """
198
+ warnings.warn(
199
+ "get_aws_credentials is deprecated and will be removed in a future release. "
200
+ "Use get_session_credentials instead.",
201
+ DeprecationWarning,
202
+ stacklevel=2,
203
+ )
204
+ if self._maybe_refreshable_resolved_source_credentials is None:
205
+ raise ValueError("Resolved source credentials are not present on the Source.")
206
+ if not isinstance(self._maybe_refreshable_resolved_source_credentials.get(), AwsCredentials):
207
+ raise ValueError("Resolved source credentials are not of type AwsCredentials.")
208
+ return cast(Refreshable[AwsCredentials], self._maybe_refreshable_resolved_source_credentials)
189
209
 
210
+ def get_session_credentials(self) -> Refreshable[SourceCredentials]:
211
+ """
190
212
  Supported Sources:
191
213
  - S3
214
+ - BigQuery
215
+ - Google Cloud Storage
192
216
  """
193
217
  if self._maybe_refreshable_resolved_source_credentials is None:
194
218
  raise ValueError("Resolved source credentials are not present on the Source.")
195
- if not isinstance(self._maybe_refreshable_resolved_source_credentials.get(), AwsCredentials):
196
- raise ValueError("Resolved source credentials are not of type AwsCredentials.")
197
219
  return self._maybe_refreshable_resolved_source_credentials
198
220
 
199
221
  def get_secret(self, key: str) -> str:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "external-systems"
3
- version = "0.104.0-rc1"
3
+ version = "0.106.0"
4
4
  description = "A Python library for interacting with Foundry Sources"
5
5
  authors = ["Palantir Technologies, Inc."]
6
6
  license = "Apache-2.0"