Metadata-Version: 2.4
Name: finalsa-sns-client
Version: 2.2.0
Summary: Lightweight AWS SNS client for Python with topic management, subscriptions, and single/batch publishing with W3C trace headers.
Project-URL: Homepage, https://github.com/finalsa/sns-client
Author-email: Luis Jimenez <luis@finalsa.com>
License: MIT License
        
        Copyright (c) 2025 Luis Diego Jiménez Delgado
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE.md
Keywords: aws,boto3,finalsa,messaging,pubsub,pydantic,sns,traceability
Requires-Python: >=3.10
Requires-Dist: boto3>=1.40.11
Requires-Dist: finalsa-common-models>=2.0.3
Requires-Dist: finalsa-traceability>=1.0.0
Requires-Dist: orjson>=3.11.2
Description-Content-Type: text/markdown

# finalsa SNS client

Lightweight AWS SNS client for Python with:

- Topic discovery/creation and basic subscription helpers
- Single and batch message publishing
- Default W3C trace headers and produced-at timestamp on messages
- Minimal test client for local/testing (`SnsClientTest`)

## Install

Requires Python 3.10+.

```bash
uv add finalsa-sns-client
```

## Quick start

```python
from finalsa.sns.client import SnsClientImpl

client = SnsClientImpl()

# Ensure a topic exists
client.get_or_create_topic("orders")

# Publish a string payload
client.publish("orders", "hello world")

# Publish a dict payload with default trace headers
client.publish_message("orders", {"id": 1, "status": "created"})

# Publish in batch (up to 10 per batch)
client.publish_messages_batch("orders", [{"id": i} for i in range(5)])
```

## Testing locally

Use the in-memory client:

```python
from finalsa.sns.client import SnsClientTest

client = SnsClientTest()
client.publish_message("test", {"ok": True})
assert client.messages("test")[0] == {"ok": True}
```

Run tests:

```bash
uv run -m pytest -q
```

## License

MIT
