capo-lambda-core 0.2.0__py3-none-any.whl → 0.4.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.
@@ -17,7 +17,7 @@ import hmac
17
17
  import re
18
18
  from collections.abc import AsyncIterator, Iterator
19
19
  from typing import Any, Literal, TypedDict, cast
20
- from urllib.parse import quote, unquote
20
+ from urllib.parse import quote
21
21
 
22
22
  import zapros
23
23
  from pywhatwgurl import URLSearchParams
@@ -134,11 +134,11 @@ def _remove_dot_segments(path: str) -> str:
134
134
  def _canonical_path(path: str, *, double_encode: bool, normalize: bool) -> str:
135
135
  """Build CanonicalURI.
136
136
 
137
- Per the SigV4 spec, every segment is URI-encoded; standard services
138
- normalize dot segments and URI-encode each segment **twice**. The
139
- rules-engine ``disableNormalizePath`` / ``disableDoubleEncoding`` flags
140
- turn those steps off — S3-family services set both, so the path is
141
- signed exactly as provided.
137
+ ``path`` is the path as sent on the wire, so it is already URI-encoded
138
+ once. Standard services normalize dot segments and URI-encode each
139
+ segment a second time. The rules-engine ``disableNormalizePath`` /
140
+ ``disableDoubleEncoding`` flags turn those steps off — S3-family
141
+ services set both, so the path is signed exactly as provided.
142
142
  """
143
143
  if not path:
144
144
  return "/"
@@ -148,9 +148,9 @@ def _canonical_path(path: str, *, double_encode: bool, normalize: bool) -> str:
148
148
  path = _remove_dot_segments(path)
149
149
  if not double_encode:
150
150
  return path
151
- decoded = unquote(path)
152
- first = quote(decoded, safe="/~")
153
- return quote(first, safe="/~")
151
+ # Never decode first: that would turn a "%2F" inside a segment (an ARN in
152
+ # a path label) into a separator and leave it out of the second encoding.
153
+ return quote(path, safe="/~")
154
154
 
155
155
 
156
156
  def _canonical_query(query: str) -> str:
@@ -125,7 +125,11 @@ def build_request(
125
125
  allow_nan=False,
126
126
  ).encode()
127
127
  headers["content-type"] = "application/json"
128
- signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
128
+ signer = (
129
+ None
130
+ if options.anonymous
131
+ else get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
132
+ )
129
133
  normalized_url = zapros.URL(url)
130
134
  for k, v in params:
131
135
  normalized_url.search_params.append(k, v)
@@ -122,7 +122,11 @@ def build_request(
122
122
  params: list[tuple[str, str]] = []
123
123
  headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
124
124
  body: bytes | None = b""
125
- signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
125
+ signer = (
126
+ None
127
+ if options.anonymous
128
+ else get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
129
+ )
126
130
  normalized_url = zapros.URL(url)
127
131
  for k, v in params:
128
132
  normalized_url.search_params.append(k, v)
@@ -121,7 +121,11 @@ def build_request(
121
121
  params: list[tuple[str, str]] = []
122
122
  headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
123
123
  body: bytes | None = b""
124
- signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
124
+ signer = (
125
+ None
126
+ if options.anonymous
127
+ else get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
128
+ )
125
129
  normalized_url = zapros.URL(url)
126
130
  for k, v in params:
127
131
  normalized_url.search_params.append(k, v)
@@ -125,7 +125,11 @@ def build_request(
125
125
  params.append(("MaxItems", str(input_["max_items"])))
126
126
  headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
127
127
  body: bytes | None = b""
128
- signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
128
+ signer = (
129
+ None
130
+ if options.anonymous
131
+ else get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
132
+ )
129
133
  normalized_url = zapros.URL(url)
130
134
  for k, v in params:
131
135
  normalized_url.search_params.append(k, v)
@@ -128,7 +128,11 @@ def build_request(
128
128
  allow_nan=False,
129
129
  ).encode()
130
130
  headers["content-type"] = "application/json"
131
- signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
131
+ signer = (
132
+ None
133
+ if options.anonymous
134
+ else get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
135
+ )
132
136
  normalized_url = zapros.URL(url)
133
137
  for k, v in params:
134
138
  normalized_url.search_params.append(k, v)
@@ -40,6 +40,7 @@ class OperationOptions:
40
40
  endpoint: str | None = None
41
41
  retry_max_attempts: int | None = None
42
42
  credentials_provider: IdentityProvider[Credentials] | None = None
43
+ anonymous: bool | None = None
43
44
 
44
45
 
45
46
  @dataclass
@@ -51,6 +52,7 @@ class AsyncOperationOptions:
51
52
  endpoint: str | None = None
52
53
  retry_max_attempts: int | None = None
53
54
  credentials_provider: IdentityProvider[Credentials] | None = None
55
+ anonymous: bool | None = None
54
56
 
55
57
 
56
58
  @dataclass
@@ -63,6 +63,7 @@ class AsyncLambdaCoreClientConfig(TypedDict, total=False, closed=True):
63
63
  use_fips: bool | None
64
64
  endpoint: str | None
65
65
  credentials_provider: IdentityProvider[Credentials] | None
66
+ anonymous: bool | None
66
67
 
67
68
 
68
69
  class AsyncLambdaCoreClient:
@@ -78,6 +79,7 @@ class AsyncLambdaCoreClient:
78
79
  endpoint: The value of the ``SDK::Endpoint`` endpoint parameter.
79
80
  credentials: AWS credentials for request signing.
80
81
  credentials_provider: Provider that resolves AWS credentials. Takes precedence over ``credentials``.
82
+ anonymous: Send requests unsigned, without resolving credentials, even for operations that require authentication.
81
83
  """
82
84
 
83
85
  def __init__(
@@ -91,10 +93,14 @@ class AsyncLambdaCoreClient:
91
93
  endpoint: str | None = None,
92
94
  credentials: Credentials | None = None,
93
95
  credentials_provider: CredentialsProvider | None = None,
96
+ anonymous: bool | None = None,
94
97
  ):
95
- self._client = AsyncClient(http_handler).wrap_with_middleware(
96
- lambda next: AuthMiddleware(next)
97
- )
98
+ client = AsyncClient(http_handler)
99
+ # The handler the user gave us, or the default one for this environment.
100
+ # The SDK middlewares wrap it below, and the credential resolvers borrow
101
+ # it for their one-off calls.
102
+ raw_handler = client.handler
103
+ self._client = client.wrap_with_middleware(lambda next: AuthMiddleware(next))
98
104
  if credentials is not None and credentials_provider is not None:
99
105
  warnings.warn(
100
106
  "Both credentials and credentials_provider given; provider takes precedence"
@@ -106,7 +112,7 @@ class AsyncLambdaCoreClient:
106
112
  resolved_credentials_provider = StaticAwsCredentialsProvider(credentials)
107
113
  if resolved_credentials_provider is None and credentials is None:
108
114
  resolved_credentials_provider = default_aws_credentials_chain(
109
- AsyncClient(http_handler)
115
+ AsyncClient(raw_handler)
110
116
  )
111
117
  self._config = AsyncLambdaCoreClientConfig(
112
118
  {
@@ -117,6 +123,7 @@ class AsyncLambdaCoreClient:
117
123
  "use_fips": use_fips,
118
124
  "endpoint": endpoint,
119
125
  "credentials_provider": resolved_credentials_provider,
126
+ "anonymous": anonymous,
120
127
  }
121
128
  )
122
129
 
@@ -148,6 +155,7 @@ class AsyncLambdaCoreClient:
148
155
  credentials_provider=overrides.get(
149
156
  "credentials_provider", self._config.get("credentials_provider")
150
157
  ),
158
+ anonymous=overrides.get("anonymous", self._config.get("anonymous")),
151
159
  )
152
160
  return interceptors_, options_
153
161
 
@@ -63,6 +63,7 @@ class LambdaCoreClientConfig(TypedDict, total=False, closed=True):
63
63
  use_fips: bool | None
64
64
  endpoint: str | None
65
65
  credentials_provider: IdentityProvider[Credentials] | None
66
+ anonymous: bool | None
66
67
 
67
68
 
68
69
  class LambdaCoreClient:
@@ -78,6 +79,7 @@ class LambdaCoreClient:
78
79
  endpoint: The value of the ``SDK::Endpoint`` endpoint parameter.
79
80
  credentials: AWS credentials for request signing.
80
81
  credentials_provider: Provider that resolves AWS credentials. Takes precedence over ``credentials``.
82
+ anonymous: Send requests unsigned, without resolving credentials, even for operations that require authentication.
81
83
  """
82
84
 
83
85
  def __init__(
@@ -91,10 +93,14 @@ class LambdaCoreClient:
91
93
  endpoint: str | None = None,
92
94
  credentials: Credentials | None = None,
93
95
  credentials_provider: CredentialsProvider | None = None,
96
+ anonymous: bool | None = None,
94
97
  ):
95
- self._client = Client(http_handler).wrap_with_middleware(
96
- lambda next: AuthMiddleware(next)
97
- )
98
+ client = Client(http_handler)
99
+ # The handler the user gave us, or the default one for this environment.
100
+ # The SDK middlewares wrap it below, and the credential resolvers borrow
101
+ # it for their one-off calls.
102
+ raw_handler = client.handler
103
+ self._client = client.wrap_with_middleware(lambda next: AuthMiddleware(next))
98
104
  if credentials is not None and credentials_provider is not None:
99
105
  warnings.warn(
100
106
  "Both credentials and credentials_provider given; provider takes precedence"
@@ -106,7 +112,7 @@ class LambdaCoreClient:
106
112
  resolved_credentials_provider = StaticAwsCredentialsProvider(credentials)
107
113
  if resolved_credentials_provider is None and credentials is None:
108
114
  resolved_credentials_provider = default_aws_credentials_chain(
109
- Client(http_handler)
115
+ Client(raw_handler)
110
116
  )
111
117
  self._config = LambdaCoreClientConfig(
112
118
  {
@@ -117,6 +123,7 @@ class LambdaCoreClient:
117
123
  "use_fips": use_fips,
118
124
  "endpoint": endpoint,
119
125
  "credentials_provider": resolved_credentials_provider,
126
+ "anonymous": anonymous,
120
127
  }
121
128
  )
122
129
 
@@ -148,6 +155,7 @@ class LambdaCoreClient:
148
155
  credentials_provider=overrides.get(
149
156
  "credentials_provider", self._config.get("credentials_provider")
150
157
  ),
158
+ anonymous=overrides.get("anonymous", self._config.get("anonymous")),
151
159
  )
152
160
  return interceptors_, options_
153
161
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: capo-lambda-core
3
- Version: 0.2.0
3
+ Version: 0.4.0
4
4
  Summary: Python SDK for AWS Lambda Core.
5
5
  Classifier: Development Status :: 4 - Beta
6
6
  Classifier: Intended Audience :: Developers
@@ -17,7 +17,7 @@ Classifier: Typing :: Typed
17
17
  Requires-Python: >=3.10
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
- Requires-Dist: zapros>=0.13.0
20
+ Requires-Dist: zapros>=0.21.0
21
21
  Provides-Extra: anyio
22
22
  Requires-Dist: anyio>=3.0; extra == "anyio"
23
23
  Provides-Extra: sso
@@ -7,13 +7,13 @@ capo_lambda_core/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  capo_lambda_core/_auth/_identity.py,sha256=ONv_NxU5ShEezSRyGAKGaxAn0R1HLGktZqKrL7xsPZw,326
8
8
  capo_lambda_core/_auth/_providers.py,sha256=L3nWWsx5C9THHTsHAadWi8bHYZLeChizCmZXziRR20A,33684
9
9
  capo_lambda_core/_auth/_signers.py,sha256=y3CBvzVRkAZ0nYg5br_HFkpKWklQE6zbca5HVCexD9o,4962
10
- capo_lambda_core/_auth/_sigv4.py,sha256=pi77jPo3cZzGXTpgKn4P6se45Rk-KjJeULF7yfBFOcg,20617
10
+ capo_lambda_core/_auth/_sigv4.py,sha256=4Zu1I9lXRTjt_CeEqrySWys72sAKtDM1FSVpi8u9Y6Q,20728
11
11
  capo_lambda_core/_auth/_zapros_handler.py,sha256=8xdfKJH-rJB2fFNajj7v5JlSn06u9ZUoOmgqUh2jptA,2978
12
- capo_lambda_core/_operations/lambda_core_api_service/create_network_connector.py,sha256=Bgn23d4Bu-boriejSAvuGmfdHg_A55vnmnWnf613j40,6907
13
- capo_lambda_core/_operations/lambda_core_api_service/delete_network_connector.py,sha256=lGXzzOnoXSomxQlV4cdhW3yYGqYLYbSASyxBjG7xZu4,6737
14
- capo_lambda_core/_operations/lambda_core_api_service/get_network_connector.py,sha256=U5n4QDGJR5YxkHsUc3oAnCMHXQ6J3J2nTWgNVssP7WM,6664
15
- capo_lambda_core/_operations/lambda_core_api_service/list_network_connectors.py,sha256=M9zwShH34wl9YVmNYBWURDkGnLVdZ8XdtPBC44XT0UA,6551
16
- capo_lambda_core/_operations/lambda_core_api_service/update_network_connector.py,sha256=G1qbpdkdYzAC2YBXBVOd721oSS1k1cF0z4dSc2AUIBI,7031
12
+ capo_lambda_core/_operations/lambda_core_api_service/create_network_connector.py,sha256=B_xdFr0XOEt_zqxeJVzaJCoMFOXDdbr3NH8zhdWMDVQ,6970
13
+ capo_lambda_core/_operations/lambda_core_api_service/delete_network_connector.py,sha256=OF7bIFmNfZc9afP7-tHzw8xr5bFcAzTzJruMWXHcN5g,6800
14
+ capo_lambda_core/_operations/lambda_core_api_service/get_network_connector.py,sha256=lP2c56VAg9YLJ-V0XsS02lcoEKTFWBdXazt14CF4Hak,6727
15
+ capo_lambda_core/_operations/lambda_core_api_service/list_network_connectors.py,sha256=ZsS5oIgIFZFSeRxrchLlxSuonH440bz_B4mRNW74Nuo,6614
16
+ capo_lambda_core/_operations/lambda_core_api_service/update_network_connector.py,sha256=Kl2DTQIh2u8Qctr2PNlOfOVOdIaD_cZb_QHTQMAaef4,7094
17
17
  capo_lambda_core/_protocol/__init__.py,sha256=MSIVV1jVmxqtMyjeNhffomlwpuVB7-tzRK4rdPDFCG8,61
18
18
  capo_lambda_core/_protocol/errors.py,sha256=LGBCYv4hreZJWCslL1jZMzcsy9_38EYIYVRyeyrPtg8,2914
19
19
  capo_lambda_core/_protocol/eventstream.py,sha256=P27Vneb7xwMlnUp5NypduhJc99OGP2CvWlxRGFMKbTQ,8943
@@ -25,9 +25,9 @@ capo_lambda_core/_rule_engine/_aws_partition.py,sha256=gxziWLrEyQKXSmsQ-skA8DdYW
25
25
  capo_lambda_core/_rule_engine/_endpoint_rule_set.py,sha256=u3ySxDh5YWDm3WGxOxAb3M7G-ab9BwQ0m7qK1Z7afjc,4993
26
26
  capo_lambda_core/_rule_engine/_endpoint_runtime.py,sha256=o94904z9c3fuJJD7vDrl_k1b9nWLueMKAXB6-OxL1Fs,13797
27
27
  capo_lambda_core/_services/_aws_config.py,sha256=rcNWCI9N9AWCsBZ4nnyhz2f513o9esWOOUnwU5MCp1g,5203
28
- capo_lambda_core/_services/_pipeline.py,sha256=p2cxtmcb7E5SlyYnMh7Xm-SSAnNVXIqS8ML0ApME04s,7990
29
- capo_lambda_core/_services/async_lambda_core.py,sha256=n9mYPx7t2OlNcVbogwFhDbi8QkwMf85DeWKhJbLeUDI,28899
30
- capo_lambda_core/_services/lambda_core.py,sha256=yxu-m6Adyctj2UmwrpN4SR0BVilyeTlzwLEZ6cCnWK8,28371
28
+ capo_lambda_core/_services/_pipeline.py,sha256=rYP5bKY9F9VnYha0m3ttOL0j_OLkTTja2dzwuWHHB14,8058
29
+ capo_lambda_core/_services/async_lambda_core.py,sha256=6Pwf3pOZ4RrW4iwTLQN7E-pMPxiqVg_F9xpcx4beHC4,29447
30
+ capo_lambda_core/_services/lambda_core.py,sha256=7-vsAVgPF5QuM6Xdynv9oLj6hjqpe8ElSYL-pTfzy5o,28919
31
31
  capo_lambda_core/errors/__init__.py,sha256=uuzIG5uMlesW1UnXndNgsNpe-tZiCFSS_UFeZHieFb0,1154
32
32
  capo_lambda_core/errors/_base.py,sha256=7RwU3dOATtaJ6mhJo8Mn3ledn_48aFJgKU2ZHM3F5mY,3034
33
33
  capo_lambda_core/errors/invalid_parameter_value_exception.py,sha256=LIOcXd089ZB6sOisAsk8Gd4yoUq8o0jHGpIAf4-Wsm4,1836
@@ -79,8 +79,8 @@ capo_lambda_core/types/update_network_connector_request.py,sha256=WjmQ7dbyKw-h58
79
79
  capo_lambda_core/types/update_network_connector_response.py,sha256=-qzPoPTfMCRyg9Upb3PrAxs84lcl2deMGeevKe3uukQ,5887
80
80
  capo_lambda_core/types/_prelude/blob.py,sha256=L57RpNwdTSboMhnddA-0PBonXBu3oPm3RAr4Ff7IjzQ,277
81
81
  capo_lambda_core/types/_prelude/timestamp.py,sha256=wfGPIPU-oBc2-PPqjNnJIElt1jXcEdb78Ux6jSX1mu0,487
82
- capo_lambda_core-0.2.0.dist-info/licenses/LICENSE,sha256=sOQjPuig7ktMdOZpG1TdsPSYAVS_9UYVXwDDbD75nVI,1072
83
- capo_lambda_core-0.2.0.dist-info/METADATA,sha256=ezu8vuNc4_lKdBcXWDkR4nk2i-8nmFp4hjVt1pWxzIk,3552
84
- capo_lambda_core-0.2.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
85
- capo_lambda_core-0.2.0.dist-info/top_level.txt,sha256=5SOL6GmRwmGKsZnqDRXU_wnO0da1632SLMxYJflxe3E,17
86
- capo_lambda_core-0.2.0.dist-info/RECORD,,
82
+ capo_lambda_core-0.4.0.dist-info/licenses/LICENSE,sha256=sOQjPuig7ktMdOZpG1TdsPSYAVS_9UYVXwDDbD75nVI,1072
83
+ capo_lambda_core-0.4.0.dist-info/METADATA,sha256=e6Encj9b56kWovVuiZbOrCuVKfkI_XIGg-j50kaXeWc,3552
84
+ capo_lambda_core-0.4.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
85
+ capo_lambda_core-0.4.0.dist-info/top_level.txt,sha256=5SOL6GmRwmGKsZnqDRXU_wnO0da1632SLMxYJflxe3E,17
86
+ capo_lambda_core-0.4.0.dist-info/RECORD,,