semvec/pypi-packages huggingface dataset:
socian-auth 0.0.8
Socian Auth Python SDK for authentication and user management
License: MIT
Requires Python: >=3.6
Keywords: socian auth authentication user-management sdk

# Socian Auth Python SDK

[![Version](https://img.shields.io/pypi/v/socian-auth)](https://pypi.org/project/socian-auth/)
[![License](https://img.shields.io/pypi/l/socian-auth)](https://opensource.org/licenses/MIT)
[![Python Versions](https://img.shields.io/pypi/pyversions/socian-auth)](https://pypi.org/project/socian-auth/)

## Overview

The Socian Auth Python SDK provides a convenient way to interact with the Socian Auth API for authentication and user management.

## Installation

You can install the library using pip:

```bash
pip install socian-auth
```
## Usage

### Initialization
```python
from socian_auth import SocianAuthApiClient

client = SocianAuthApiClient(
    client_id="your_client_id",
    client_secret="your_client_secret",
    ssh_public_key="your_ssh_public_key"
)
```
### Getting Intent
```python
intent_obj = client.get_intent("auth.signIn", "http://localhost:3000/auth/callback")
print(intent_obj)
```

### Checking User Existence
```python
email = "example@example.com"
is_user_exist = client.check_user_exists(intent_id=intent_obj.intent_id, email=email)
print(is_user_exist)
```

### User Signup
```python
user_info = client.user_signup(intent_id=intent_obj.intent_id, name="John Doe", email=email, password="password123")
print(user_info)
```


### User Signin
```python
login_data = client.user_signin(email=email, password="password123")
print(login_data)
```


### User Information
```python
user_info = client.user_info(access_token=login_data.access_token)
print(user_info)
```


## Documentation

For more details and API documentation, please refer to [Socian Auth SDK Documentation](https://github.com/Socian-Ltd/socian_auth_sdk_python.git).

## Contributing

If you find any issues or have suggestions for improvement, please open an issue or create a pull request on [GitHub](https://github.com/Socian-Ltd/socian_auth_sdk_python.git).

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
python3-eventbus 0.1.6
Event bus implementation for Python
License: MIT
Requires Python: >=3.12,<4.0
Keywords: eventbus,event,bus,python

# PyEventBus
EventBus implementations in Python. It allows you to easily publish custom domain events and subscribe commands to them.

## Installation
```bash
pip install python3-eventbus
```

## Usage
1. Create the event bus (see "EventBus types" section for more details)
```python
sender_topic = boto3.resource("sns", region_name="us-east-1").Topic(sns_sender_arn)
eventbus = SNSEventBus(sender_topic)
```

2. Define your event
```python
@dataclass
class UserCreatedEvent(DomainEvent):
    user_id: str

    def to_dict(self) -> dict[str, str]:
        return {"user_id": self.user_id}

    @classmethod
    def from_dict(cls, data: dict[str, str]) -> Self:
        return cls(data["user_id"])
```
3. Define the subscriber
```python
@dataclass
class SendWelcomeEmailCommand:
    eventbus: EventBus

    def __post_init__(self):
        self.eventbus.subscribe(
            UserCreatedEvent, # The event to subscribe to
            lambda event: self.send_welcome_email(event.user_id), # The callback
            self.__class__, # The subscriber entity
        )

    def send_welcome_email(self, user_id: str):
        ...Business logic...
```
4. Register the subscriber
```python
send_welcome_email_command = SendWelcomeEmailCommand(eventbus) # This will execute the __post_init__ method (dataclass feature)
```

5. Publish the event
```python
eventbus.publish(UserCreatedEvent("user_id"))
```

6. From your controller, rebuild the domain event based on the subscriptions
```python
def lambda_handler(event: dict[str, Any], context: Any):
    raw_domain_event = _unwrap_event(event) # Remove event metadata (SQS, SNS, etc.)
    domain_event = eventbus.build_event_from_subscriptions(
        raw_domain_event["event_type"],
        raw_domain_event["event"],
    )
```

## EventBus types
### AWS: SNSEventBus
This implementation will forward events to an AWS SNS topic. The topic must be created before the event bus is used.

```python
sender_topic = boto3.resource("sns", region_name="us-east-1").Topic(sns_sender_arn)
eventbus = SNSEventBus(sender_topic)
```
Complete example: [aws_sns.ipynb](./examples/aws_sns.ipynb)