dex-connector-amazon-dynamodb 0.1.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 (28) hide show
  1. dex_connector_amazon_dynamodb-0.1.0/.gitignore +16 -0
  2. dex_connector_amazon_dynamodb-0.1.0/LICENSE +21 -0
  3. dex_connector_amazon_dynamodb-0.1.0/PKG-INFO +15 -0
  4. dex_connector_amazon_dynamodb-0.1.0/README.md +3 -0
  5. dex_connector_amazon_dynamodb-0.1.0/examples/item_lookup/README.md +3 -0
  6. dex_connector_amazon_dynamodb-0.1.0/examples/item_lookup/__init__.py +3 -0
  7. dex_connector_amazon_dynamodb-0.1.0/examples/item_lookup/flow.py +79 -0
  8. dex_connector_amazon_dynamodb-0.1.0/examples/item_lookup/integration_test.py +78 -0
  9. dex_connector_amazon_dynamodb-0.1.0/examples/item_lookup/worker.py +52 -0
  10. dex_connector_amazon_dynamodb-0.1.0/pyproject.toml +37 -0
  11. dex_connector_amazon_dynamodb-0.1.0/src/dex_connectors/amazon_dynamodb/__init__.py +22 -0
  12. dex_connector_amazon_dynamodb-0.1.0/src/dex_connectors/amazon_dynamodb/_generated/__init__.py +2 -0
  13. dex_connector_amazon_dynamodb-0.1.0/src/dex_connectors/amazon_dynamodb/_generated/config.py +28 -0
  14. dex_connector_amazon_dynamodb-0.1.0/src/dex_connectors/amazon_dynamodb/_generated/connection.py +144 -0
  15. dex_connector_amazon_dynamodb-0.1.0/src/dex_connectors/amazon_dynamodb/_generated/definitions.py +40 -0
  16. dex_connector_amazon_dynamodb-0.1.0/src/dex_connectors/amazon_dynamodb/_generated/mock.py +74 -0
  17. dex_connector_amazon_dynamodb-0.1.0/src/dex_connectors/amazon_dynamodb/_generated/models.py +26 -0
  18. dex_connector_amazon_dynamodb-0.1.0/src/dex_connectors/amazon_dynamodb/_generated/steps.py +81 -0
  19. dex_connector_amazon_dynamodb-0.1.0/src/dex_connectors/amazon_dynamodb/client.py +266 -0
  20. dex_connector_amazon_dynamodb-0.1.0/src/dex_connectors/amazon_dynamodb/connection.py +8 -0
  21. dex_connector_amazon_dynamodb-0.1.0/src/dex_connectors/amazon_dynamodb/dex-connector.json +76 -0
  22. dex_connector_amazon_dynamodb-0.1.0/src/dex_connectors/amazon_dynamodb/dynamodbmock/__init__.py +6 -0
  23. dex_connector_amazon_dynamodb-0.1.0/src/dex_connectors/amazon_dynamodb/models.py +8 -0
  24. dex_connector_amazon_dynamodb-0.1.0/src/dex_connectors/amazon_dynamodb/sigv4.py +82 -0
  25. dex_connector_amazon_dynamodb-0.1.0/src/dex_connectors/amazon_dynamodb/steps.py +5 -0
  26. dex_connector_amazon_dynamodb-0.1.0/tests/test_conformance.py +39 -0
  27. dex_connector_amazon_dynamodb-0.1.0/tests/test_manifest_contract.py +15 -0
  28. dex_connector_amazon_dynamodb-0.1.0/uv.lock +932 -0
@@ -0,0 +1,16 @@
1
+ .DS_Store
2
+ __pycache__/
3
+ *.py[cod]
4
+ node_modules/
5
+ dist/
6
+ sdkpython/dist/dex_connectors_sdk-0.1.0-py3-none-any.whl
7
+ /.bin/dexcli
8
+ /.bin/dex-server-zd
9
+ /sdkpython/.dexcli-data/
10
+ site/.catalog.yaml
11
+ coverage/
12
+ *.out
13
+ *.test
14
+ go.work
15
+ go.work.sum
16
+ .idea/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Super Durable
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated keyation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.5
2
+ Name: dex-connector-amazon-dynamodb
3
+ Version: 0.1.0
4
+ Summary: Amazon DynamoDB connector for Dex Flows
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.11
8
+ Requires-Dist: dex-connectors-sdk==0.1.0
9
+ Requires-Dist: dex-python-sdk>=1.28.0
10
+ Requires-Dist: httpx>=0.27
11
+ Description-Content-Type: text/markdown
12
+
13
+ # Amazon DynamoDB Python package
14
+
15
+ `Client.get_item()` binds the signed `getItem` Query. `GetItemInput` contains `table_name`, the complete DynamoDB `key` AttributeValue map, and `consistent_read`. The `found` output contains `ItemResult(exists=True, item=...)`; `missing` has an empty item map. See the [connector guide](../README.md) for configuration and IAM permissions. The [runnable Flow](examples/item_lookup/README.md) exercises a real Dex Worker with a local provider fixture. Live AWS access has not been verified.
@@ -0,0 +1,3 @@
1
+ # Amazon DynamoDB Python package
2
+
3
+ `Client.get_item()` binds the signed `getItem` Query. `GetItemInput` contains `table_name`, the complete DynamoDB `key` AttributeValue map, and `consistent_read`. The `found` output contains `ItemResult(exists=True, item=...)`; `missing` has an empty item map. See the [connector guide](../README.md) for configuration and IAM permissions. The [runnable Flow](examples/item_lookup/README.md) exercises a real Dex Worker with a local provider fixture. Live AWS access has not been verified.
@@ -0,0 +1,3 @@
1
+ # Python DynamoDB item lookup example
2
+
3
+ The Worker runs `AmazonDynamoDBItemLookupPython` through the static `amazon-dynamodb` connection and stores the item result in an Attribute. From `connectors/amazon/dynamodb/python`, run `uv run python -m examples.item_lookup.worker` with the project `DEX_PROJECT_*` environment and a running `dexcli dev` service. Start the Flow with a unique ID and `GetItemInput(table_name="Examples", key={"pk": {"S": "example"}}, consistent_read=False)`. Optional branches are unwired. `integration_test.py` runs the same Flow against real Dex and a local provider fixture. Configure the connection with the [connector guide](../../../README.md).
@@ -0,0 +1,3 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Amazon DynamoDB item lookup example Flow."""
@@ -0,0 +1,79 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Runnable Amazon DynamoDB item lookup Flow using getItem."""
4
+
5
+ import dex
6
+ from dex_connectors.sdk import QueryResult
7
+
8
+ from dex_connectors.amazon_dynamodb import (
9
+ Connection,
10
+ GetItemInput,
11
+ ItemResult,
12
+ new_get_item_step,
13
+ )
14
+
15
+ FLOW_TYPE = "AmazonDynamoDBItemLookupPython"
16
+ CONNECTION_NAME = "amazon-dynamodb"
17
+ _CALL_STEP_TYPE = "CallGetItem"
18
+ _RESULT = dex.Attribute("dynamodb-item-lookup", ItemResult)
19
+
20
+
21
+ def map_to_operation_input(request: GetItemInput) -> GetItemInput:
22
+ """Send the request unchanged."""
23
+ return request
24
+
25
+
26
+ # dex:group group-id:dynamodb group-label:"Amazon DynamoDB"
27
+ # dex:explanation text:"Start the Amazon DynamoDB request."
28
+ class _StartRequest(dex.Step[GetItemInput]):
29
+ def get_step_type(self) -> str:
30
+ return "StartGetItemRequest"
31
+
32
+ def execute(self, context: dex.Context, input: GetItemInput) -> dex.StepDecision:
33
+ return dex.go_to(dex.StepRef("CallGetItem"), input)
34
+
35
+
36
+ # dex:group group-id:dynamodb group-label:"Amazon DynamoDB"
37
+ # dex:explanation text:"Record the provider result and complete the Flow."
38
+ class _CompleteRequest(dex.Step[QueryResult[ItemResult]]):
39
+ def get_step_type(self) -> str:
40
+ return "CompleteGetItemRequest"
41
+
42
+ def execute(self, context: dex.Context, input: QueryResult[ItemResult]) -> dex.StepDecision:
43
+ _RESULT.set(context, input.value)
44
+ return dex.graceful_complete(input.value)
45
+
46
+
47
+ class ItemLookupFlow(dex.Flow[GetItemInput]):
48
+ """Read one item through the static amazon-dynamodb connection."""
49
+
50
+ def __init__(self, connection: Connection) -> None:
51
+ if connection.reference.name != CONNECTION_NAME:
52
+ raise ValueError("item lookup requires the static amazon-dynamodb connection")
53
+ self._start = _StartRequest()
54
+ self._complete = _CompleteRequest()
55
+ self._call = new_get_item_step(
56
+ step_type=_CALL_STEP_TYPE,
57
+ step_input_type=GetItemInput,
58
+ annotations={
59
+ "groupId": "dynamodb",
60
+ "groupLabel": "Amazon DynamoDB",
61
+ "explanation": "Read one item from the connected Amazon DynamoDB account.",
62
+ },
63
+ connection=connection,
64
+ connection_name=CONNECTION_NAME,
65
+ map_to_operation_input=map_to_operation_input,
66
+ found=self._complete,
67
+ )
68
+
69
+ def get_flow_type(self) -> str:
70
+ """Return the stable Flow identity used in Dex Web."""
71
+ return "AmazonDynamoDBItemLookupPython"
72
+
73
+ def get_steps(self) -> dex.StepList[GetItemInput]:
74
+ """Register the start, provider read, and completion Steps."""
75
+ return dex.StepList.start_step(self._start).other_steps(self._call, self._complete)
76
+
77
+ def get_persistence_schema(self) -> dex.PersistenceSchema:
78
+ """Persist the provider result."""
79
+ return dex.PersistenceSchema.of(_RESULT)
@@ -0,0 +1,78 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Real Dex Worker and Client verification for the Amazon DynamoDB Python Flow."""
4
+
5
+ import asyncio
6
+ import os
7
+ from datetime import timedelta
8
+ from pathlib import Path
9
+ from uuid import uuid4
10
+
11
+ import dex
12
+ import httpx
13
+ import pytest
14
+ from dex_connectors.sdk import ConnectionRef, SecretString, StaticCredentialProvider
15
+
16
+ from dex_connectors.amazon_dynamodb import (
17
+ Client,
18
+ Config,
19
+ Credentials,
20
+ GetItemInput,
21
+ ItemResult,
22
+ new_connection,
23
+ )
24
+
25
+ from .flow import CONNECTION_NAME, ItemLookupFlow
26
+
27
+
28
+ @pytest.mark.asyncio
29
+ async def test_item_lookup_retries_503(tmp_path: Path) -> None:
30
+ """Run the checked-in Flow across real Dex retry and persistence boundaries."""
31
+ address = os.environ["DEX_FLOW_SERVICE_ADDRESS"]
32
+ requests: list[httpx.Request] = []
33
+
34
+ def answer(request: httpx.Request) -> httpx.Response:
35
+ requests.append(request)
36
+ assert request.method == "POST"
37
+ assert request.url.path == "/"
38
+ assert request.headers["X-Amz-Target"] == "DynamoDB_20120810.GetItem"
39
+ assert "dynamodb/aws4_request" in request.headers["Authorization"]
40
+ if len(requests) == 1:
41
+ return httpx.Response(503)
42
+ return httpx.Response(
43
+ 200,
44
+ json={"Item": {"pk": {"S": "example"}}},
45
+ )
46
+
47
+ reference = ConnectionRef("amazon-dynamodb", CONNECTION_NAME)
48
+ credentials = Credentials(
49
+ SecretString("AKIADYNAMOCONNECTOR"), SecretString("dynamodb-test-secret"), SecretString("")
50
+ )
51
+ async with httpx.AsyncClient(transport=httpx.MockTransport(answer)) as http_client:
52
+ provider = Client(
53
+ Config(endpoint="http://127.0.0.1:12345", region="eu-west-1"),
54
+ StaticCredentialProvider({reference: credentials}),
55
+ http_client,
56
+ )
57
+ connection = new_connection(provider, reference)
58
+ flow = ItemLookupFlow(connection)
59
+ registry = dex.Registry([flow], allow_async_handlers=True)
60
+ cache = dex.open_blob_cache(dex.BlobCacheConfig(str(tmp_path / "blobs"), 1 << 24))
61
+ worker = dex.AsyncWorker(registry, cache, dex.WorkerOptions(server_address=address))
62
+ worker_task = asyncio.create_task(worker.start())
63
+ try:
64
+ await worker.wait_pull_registered(timeout=15)
65
+ async with dex.AsyncClient(registry, cache, dex.ClientOptions(server_address=address)) as client:
66
+ flow_id = f"dynamodb-python-{uuid4().hex}"
67
+ await client.start_flow(
68
+ flow, flow_id, GetItemInput(table_name="Examples", key={"pk": {"S": "example"}})
69
+ )
70
+ result = await asyncio.wait_for(client.wait_for_flow(flow_id, timedelta(seconds=25)), 30)
71
+ assert result.status == dex.FlowStatus.COMPLETED, result.error_message
72
+ assert result.single_output(ItemResult).item == {"pk": {"S": "example"}}
73
+ assert len(requests) == 2
74
+ finally:
75
+ await worker.stop()
76
+ await worker_task
77
+ cache.close()
78
+ await connection.aclose()
@@ -0,0 +1,52 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Worker entrypoint for the Amazon DynamoDB item lookup Flow."""
4
+
5
+ import asyncio
6
+ import os
7
+ import tempfile
8
+ from pathlib import Path
9
+
10
+ import dex
11
+ from dex_connectors.sdk.projectconfig import load_from_environment
12
+
13
+ from dex_connectors.amazon_dynamodb import new_project_connection
14
+
15
+ from .flow import CONNECTION_NAME, ItemLookupFlow
16
+
17
+
18
+ async def run_worker() -> None:
19
+ """Load the named Dex Web connection and serve Amazon DynamoDB reads."""
20
+ project = await load_from_environment()
21
+ connection = None
22
+ cache = None
23
+ try:
24
+ connection = new_project_connection(project, CONNECTION_NAME)
25
+ registry = dex.Registry([ItemLookupFlow(connection)], allow_async_handlers=True)
26
+ cache_directory = os.environ.get(
27
+ "DEX_BLOB_CACHE_DIR",
28
+ str(Path(tempfile.gettempdir()) / "dex-dynamodb-item-lookup-blobs"),
29
+ )
30
+ cache = dex.open_blob_cache(dex.BlobCacheConfig(cache_directory, 1 << 30))
31
+ worker = dex.AsyncWorker(
32
+ registry,
33
+ cache,
34
+ dex.WorkerOptions(server_address=os.environ.get("DEX_FLOW_SERVICE_ADDRESS", "localhost:8801")),
35
+ )
36
+ async with worker:
37
+ await worker.start()
38
+ finally:
39
+ if connection is not None:
40
+ await connection.aclose()
41
+ if cache is not None:
42
+ cache.close()
43
+ await project.close()
44
+
45
+
46
+ def main() -> None:
47
+ """Run until the Worker stops or the process receives an interrupt."""
48
+ asyncio.run(run_worker())
49
+
50
+
51
+ if __name__ == "__main__":
52
+ main()
@@ -0,0 +1,37 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "dex-connector-amazon-dynamodb"
7
+ version = "0.1.0"
8
+ description = "Amazon DynamoDB connector for Dex Flows"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ dependencies = ["dex-connectors-sdk==0.1.0", "dex-python-sdk>=1.28.0", "httpx>=0.27"]
13
+
14
+ [dependency-groups]
15
+ dev = ["pytest>=8", "pytest-asyncio>=0.24", "mypy>=1.13", "ruff>=0.7", "pyyaml>=6", "types-PyYAML>=6"]
16
+
17
+ [tool.hatch.build.targets.wheel]
18
+ packages = ["src/dex_connectors"]
19
+
20
+ [tool.pytest.ini_options]
21
+ testpaths = ["tests"]
22
+ pythonpath = [".", "src"]
23
+ asyncio_mode = "auto"
24
+ asyncio_default_fixture_loop_scope = "function"
25
+
26
+ [tool.mypy]
27
+ python_version = "3.11"
28
+ strict = true
29
+ mypy_path = "src"
30
+ explicit_package_bases = true
31
+
32
+ [tool.ruff]
33
+ target-version = "py311"
34
+ line-length = 110
35
+
36
+ [tool.ruff.lint]
37
+ select = ["E", "F", "I", "UP", "B"]
@@ -0,0 +1,22 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Amazon DynamoDB key Queries for Dex Flows."""
4
+
5
+ from .client import Client, Config, Credentials, GetItemOperation
6
+ from .connection import Connection, new_connection, new_connection_with_operations, new_project_connection
7
+ from .models import GetItemInput, ItemResult
8
+ from .steps import new_get_item_step
9
+
10
+ __all__ = [
11
+ "Client",
12
+ "Config",
13
+ "Connection",
14
+ "Credentials",
15
+ "GetItemInput",
16
+ "ItemResult",
17
+ "GetItemOperation",
18
+ "new_connection",
19
+ "new_connection_with_operations",
20
+ "new_get_item_step",
21
+ "new_project_connection",
22
+ ]
@@ -0,0 +1,2 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
@@ -0,0 +1,28 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ # ruff: noqa
4
+
5
+ from dataclasses import dataclass
6
+
7
+ from dex_connectors.sdk import SecretString
8
+
9
+
10
+ @dataclass(frozen=True, slots=True)
11
+ class Config:
12
+
13
+ endpoint: str
14
+ region: str = "us-east-1"
15
+ timeout_seconds: float = 15
16
+ max_response_bytes: int = 2097152
17
+
18
+ setattr(Config, '__module__', 'dex_connectors.amazon_dynamodb.client')
19
+
20
+
21
+ @dataclass(frozen=True, slots=True)
22
+ class Credentials:
23
+
24
+ access_key_id: SecretString
25
+ secret_access_key: SecretString
26
+ session_token: SecretString
27
+
28
+ setattr(Credentials, '__module__', 'dex_connectors.amazon_dynamodb.client')
@@ -0,0 +1,144 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ # ruff: noqa
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+ from dex_connectors.sdk import ConnectionRef, Query, Call, SecretString
9
+ from dex_connectors.sdk.projectconfig import ConnectionKey, LoadedProject
10
+
11
+ from ..client import Client, Config, Credentials
12
+ from .definitions import CONNECTOR_ID, GET_ITEM_DEFINITION
13
+ from ..models import GetItemInput, ItemResult
14
+
15
+ class Connection:
16
+
17
+ __slots__ = ('_get_item', '_client', 'reference')
18
+
19
+ def __init__(self,
20
+ reference: ConnectionRef,
21
+ get_item: Query[GetItemInput, ItemResult],
22
+ client: Client | None = None,
23
+ ) -> None:
24
+ reference.validate()
25
+ if reference.provider != CONNECTOR_ID or get_item is None:
26
+ raise ValueError("Amazon DynamoDB connection provider and operations are required")
27
+ if get_item.definition().operation != GET_ITEM_DEFINITION.operation:
28
+ raise ValueError("Amazon DynamoDB connection operation identity differs")
29
+ self.reference = reference
30
+ self._get_item = get_item
31
+ self._client = client
32
+
33
+ def get_item(self) -> Query[GetItemInput, ItemResult]:
34
+ return self._get_item
35
+
36
+ async def aclose(self) -> None:
37
+ if self._client is not None:
38
+ await self._client.aclose()
39
+
40
+ def __repr__(self) -> str:
41
+ return "amazon_dynamodb.Connection([REDACTED])"
42
+
43
+ def __reduce__(self) -> tuple[object, ...]:
44
+ raise TypeError("Amazon DynamoDB connections cannot be serialized")
45
+
46
+ setattr(Connection, '__module__', 'dex_connectors.amazon_dynamodb.connection')
47
+
48
+
49
+ def new_connection(client: Client, reference: ConnectionRef) -> Connection:
50
+ if client is None:
51
+ raise ValueError("Amazon DynamoDB client is required")
52
+ return Connection(reference, client.get_item(), client)
53
+
54
+ setattr(new_connection, '__module__', 'dex_connectors.amazon_dynamodb.connection')
55
+
56
+
57
+ def new_connection_with_operations(
58
+ get_item: Query[GetItemInput, ItemResult],
59
+ reference: ConnectionRef,
60
+ ) -> Connection:
61
+ return Connection(reference, get_item)
62
+
63
+ setattr(new_connection_with_operations, '__module__', 'dex_connectors.amazon_dynamodb.connection')
64
+
65
+
66
+ class _ProjectCredentialSource:
67
+
68
+ def __init__(self, project: LoadedProject, key: ConnectionKey) -> None:
69
+ self.project = project
70
+ self.key = key
71
+
72
+ async def resolve(self, call: Call) -> Credentials:
73
+ material = await self.project.resolve_credential(self.key, str(call.id))
74
+ if not isinstance(material, dict):
75
+ raise ValueError("Amazon DynamoDB stored credential does not match the connector credential fields")
76
+ if set(material) - set(('access_key_id', 'secret_access_key', 'session_token')):
77
+ raise ValueError("Amazon DynamoDB stored credential does not match the connector credential fields")
78
+ access_key_id = material.get("access_key_id")
79
+ if access_key_id is not None and not (isinstance(access_key_id, str)):
80
+ raise ValueError("Amazon DynamoDB credential access_key_id has an invalid type")
81
+ secret_access_key = material.get("secret_access_key")
82
+ if secret_access_key is not None and not (isinstance(secret_access_key, str)):
83
+ raise ValueError("Amazon DynamoDB credential secret_access_key has an invalid type")
84
+ session_token = material.get("session_token")
85
+ if session_token is not None and not (isinstance(session_token, str)):
86
+ raise ValueError("Amazon DynamoDB credential session_token has an invalid type")
87
+ if not access_key_id:
88
+ raise ValueError("Amazon DynamoDB credential access_key_id is required")
89
+ if not secret_access_key:
90
+ raise ValueError("Amazon DynamoDB credential secret_access_key is required")
91
+ return Credentials(SecretString(access_key_id), SecretString(secret_access_key), SecretString(session_token or ''))
92
+
93
+
94
+ def new_project_connection(
95
+ project: LoadedProject, connection_name: str, http_client: httpx.AsyncClient | None = None
96
+ ) -> Connection:
97
+ if project is None:
98
+ raise ValueError("Amazon DynamoDB connection requires loaded project configuration")
99
+ reference = ConnectionRef(CONNECTOR_ID, connection_name)
100
+ reference.validate()
101
+ key = ConnectionKey(CONNECTOR_ID, connection_name)
102
+ matching = [
103
+ entry
104
+ for entry in project.configuration.connections
105
+ if entry.connector_id == CONNECTOR_ID and entry.connection_name == connection_name
106
+ ]
107
+ if len(matching) != 1:
108
+ raise ValueError("Amazon DynamoDB project connection is missing or duplicated")
109
+ if matching[0].provider != CONNECTOR_ID:
110
+ raise ValueError("Amazon DynamoDB project connection provider differs")
111
+ config = _decode_config(matching[0].configuration)
112
+ client = Client(config, _ProjectCredentialSource(project, key), http_client)
113
+ return new_connection(client, reference)
114
+
115
+ setattr(new_project_connection, '__module__', 'dex_connectors.amazon_dynamodb.connection')
116
+
117
+
118
+ def _decode_config(value: dict[str, Any]) -> Config:
119
+ if set(value) - {"region", "endpoint", "timeout", "maxResponseBytes"}:
120
+ raise ValueError("Amazon DynamoDB configuration has unknown fields")
121
+ config_arguments: dict[str, Any] = {}
122
+ if "region" in value and value["region"] != '':
123
+ region = value["region"]
124
+ if not (isinstance(region, str)):
125
+ raise ValueError("Amazon DynamoDB configuration region has an invalid type")
126
+ config_arguments['region'] = region
127
+ if "endpoint" in value and value["endpoint"] != '':
128
+ endpoint = value["endpoint"]
129
+ if not (isinstance(endpoint, str)):
130
+ raise ValueError("Amazon DynamoDB configuration endpoint has an invalid type")
131
+ config_arguments['endpoint'] = endpoint
132
+ else:
133
+ config_arguments['endpoint'] = ''
134
+ if "timeout" in value and value["timeout"] != '':
135
+ timeout = value["timeout"]
136
+ if not (type(timeout) is int):
137
+ raise ValueError("Amazon DynamoDB configuration timeout has an invalid type")
138
+ config_arguments['timeout_seconds'] = timeout / 1_000_000_000
139
+ if "maxResponseBytes" in value and value["maxResponseBytes"] != '':
140
+ max_response_bytes = value["maxResponseBytes"]
141
+ if not (type(max_response_bytes) is int):
142
+ raise ValueError("Amazon DynamoDB configuration maxResponseBytes has an invalid type")
143
+ config_arguments['max_response_bytes'] = max_response_bytes
144
+ return Config(**config_arguments)
@@ -0,0 +1,40 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ # ruff: noqa
4
+
5
+ from datetime import timedelta
6
+
7
+ from dex_connectors.sdk import (
8
+ BranchDefinition,
9
+ MutationDefinition,
10
+ OperationRef,
11
+ QueryDefinition,
12
+ RetryPolicy,
13
+ StepDefaults,
14
+ default_connector_step_execute_retry_policy,
15
+ )
16
+
17
+ CONNECTOR_ID = "amazon-dynamodb"
18
+ PROVIDER = "amazon-dynamodb"
19
+ GET_ITEM_OPERATION_ID = "getItem"
20
+ DEFECT = "defect"
21
+ FOUND = "found"
22
+ INVALID_RESPONSE = "invalidResponse"
23
+ MISSING = "missing"
24
+ PROVIDER_REJECTED = "providerRejected"
25
+
26
+ GET_ITEM_DEFINITION = QueryDefinition(
27
+ OperationRef(CONNECTOR_ID, GET_ITEM_OPERATION_ID),
28
+ (
29
+ BranchDefinition(FOUND, "DynamoDB returned the item.", False),
30
+ BranchDefinition(MISSING, "The table has no item with that key.", True),
31
+ BranchDefinition(PROVIDER_REJECTED, "DynamoDB conclusively rejected the request or credentials.", True),
32
+ BranchDefinition(INVALID_RESPONSE, "DynamoDB returned malformed or oversized item JSON.", True),
33
+ BranchDefinition(DEFECT, "The table, key, endpoint, Region, or credentials are invalid.", True),
34
+ ),
35
+ StepDefaults(
36
+ timedelta(seconds=30),
37
+ 2,
38
+ execute_retry=default_connector_step_execute_retry_policy(),
39
+ ),
40
+ )
@@ -0,0 +1,74 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ # ruff: noqa
4
+
5
+ from datetime import datetime
6
+
7
+ from dex_connectors.sdk import ConnectionRef, Failure, FailureKind
8
+ from dex_connectors.sdk.connectormock import Case, Query
9
+
10
+ from ..connection import Connection, new_connection_with_operations
11
+ from ..models import GetItemInput, ItemResult
12
+ from .definitions import CONNECTOR_ID, DEFECT, FOUND, GET_ITEM_DEFINITION, INVALID_RESPONSE, MISSING, PROVIDER_REJECTED
13
+
14
+ def get_item_found(value: ItemResult, failure: Failure | None = None) -> Case[ItemResult]:
15
+ return Case.branch_result(FOUND, value, failure)
16
+
17
+ setattr(get_item_found, '__module__', "dex_connectors.amazon_dynamodb.dynamodbmock")
18
+
19
+ def get_item_missing(value: ItemResult, failure: Failure | None = None) -> Case[ItemResult]:
20
+ return Case.branch_result(MISSING, value, failure)
21
+
22
+ setattr(get_item_missing, '__module__', "dex_connectors.amazon_dynamodb.dynamodbmock")
23
+
24
+ def get_item_provider_rejected(value: ItemResult, failure: Failure | None = None) -> Case[ItemResult]:
25
+ return Case.branch_result(PROVIDER_REJECTED, value, failure)
26
+
27
+ setattr(get_item_provider_rejected, '__module__', "dex_connectors.amazon_dynamodb.dynamodbmock")
28
+
29
+ def get_item_invalid_response(value: ItemResult, failure: Failure | None = None) -> Case[ItemResult]:
30
+ return Case.branch_result(INVALID_RESPONSE, value, failure)
31
+
32
+ setattr(get_item_invalid_response, '__module__', "dex_connectors.amazon_dynamodb.dynamodbmock")
33
+
34
+ def get_item_defect(value: ItemResult, failure: Failure | None = None) -> Case[ItemResult]:
35
+ return Case.branch_result(DEFECT, value, failure)
36
+
37
+ setattr(get_item_defect, '__module__', "dex_connectors.amazon_dynamodb.dynamodbmock")
38
+
39
+ def get_item_retry(failure: Failure, after_seconds: float = 0) -> Case[ItemResult]:
40
+ return Case.retry(failure, after_seconds)
41
+
42
+ setattr(get_item_retry, '__module__', "dex_connectors.amazon_dynamodb.dynamodbmock")
43
+
44
+ def get_item_found_default() -> Case[ItemResult]:
45
+ return Case.branch_result(FOUND, ItemResult(exists=True, item={'pk': {'S': 'example'}}))
46
+
47
+ setattr(get_item_found_default, '__module__', "dex_connectors.amazon_dynamodb.dynamodbmock")
48
+
49
+
50
+ class Mock:
51
+
52
+ def __init__(self, connection_name: str = "amazon-dynamodb") -> None:
53
+ self.get_item_script: Query[GetItemInput, ItemResult] = Query(GET_ITEM_DEFINITION)
54
+ self.get_item_script.default(get_item_found_default())
55
+ self._connection = new_connection_with_operations(
56
+ get_item=self.get_item_script,
57
+ reference=ConnectionRef(CONNECTOR_ID, connection_name),
58
+ )
59
+
60
+ def connection(self) -> Connection:
61
+ return self._connection
62
+
63
+ setattr(Mock, '__module__', "dex_connectors.amazon_dynamodb.dynamodbmock")
64
+
65
+ __all__ = [
66
+ "Mock",
67
+ "get_item_found",
68
+ "get_item_missing",
69
+ "get_item_provider_rejected",
70
+ "get_item_invalid_response",
71
+ "get_item_defect",
72
+ "get_item_retry",
73
+ "get_item_found_default",
74
+ ]
@@ -0,0 +1,26 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ # ruff: noqa
4
+
5
+ from dataclasses import dataclass, field as _dataclass_field
6
+ from typing import Any
7
+
8
+ # GetItemInput identifies a table row by all of its S, N, or B key attributes.
9
+ @dataclass(frozen=True, slots=True)
10
+ class GetItemInput:
11
+ table_name: str = _dataclass_field(default='', metadata={'dex_json_name': 'tableName'})
12
+ key: dict[str, Any] | None = None
13
+ consistent_read: bool = _dataclass_field(default=False, metadata={'dex_json_name': 'consistentRead'})
14
+
15
+
16
+ setattr(GetItemInput, '__module__', 'dex_connectors.amazon_dynamodb.models')
17
+
18
+
19
+ # ItemResult returns the item's AttributeValue map when it exists.
20
+ @dataclass(frozen=True, slots=True)
21
+ class ItemResult:
22
+ exists: bool = False
23
+ item: dict[str, Any] | None = None
24
+
25
+
26
+ setattr(ItemResult, '__module__', 'dex_connectors.amazon_dynamodb.models')